From patchwork Thu Aug 20 09:22:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 265716 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96851C433DF for ; Thu, 20 Aug 2020 10:15:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72E4C2078D for ; Thu, 20 Aug 2020 10:15:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597918539; bh=jEodp2XBbycLqhu6saZoTXE2lkh+HwkeWPk6lozDk6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Tzeo47us6Az/DL6phtEB3z+3RgeZYib3v/HIJzPRlK9zoYiavGkw1fmgP0OtXDoXz 9+/aCTYpmnlz/GYw+DRV4+cCVl8dpaeOgsn2RQlJQYFN/VMnoZdipjZhbQBYgiDkJz 4B3FINsawE/nYAg6rEb9fwfnsIN4CVFB+pLrwUv0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731134AbgHTKPh (ORCPT ); Thu, 20 Aug 2020 06:15:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:34712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731251AbgHTKPY (ORCPT ); Thu, 20 Aug 2020 06:15:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AC5782078D; Thu, 20 Aug 2020 10:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597918524; bh=jEodp2XBbycLqhu6saZoTXE2lkh+HwkeWPk6lozDk6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uPtWvkz21DPqMsQGt3pYOAATLiuei3Z7STjuEqC/OZbSw8sfDVFfZ5io4gUcTwleS gV341705pnj9mH4QL4Ab7v3Or5eMFWSpA4T1h+QE1k+Bfa0hTCQ/LrfSDjsBYq/w0k vOq5plWp8WPWRDHrQ0BMnKypaPloiR0QCM08YRgc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Joerg Roedel , Sasha Levin Subject: [PATCH 4.14 202/228] iommu/omap: Check for failure of a call to omap_iommu_dump_ctx Date: Thu, 20 Aug 2020 11:22:57 +0200 Message-Id: <20200820091617.641668399@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091607.532711107@linuxfoundation.org> References: <20200820091607.532711107@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Colin Ian King [ Upstream commit dee9d154f40c58d02f69acdaa5cfd1eae6ebc28b ] It is possible for the call to omap_iommu_dump_ctx to return a negative error number, so check for the failure and return the error number rather than pass the negative value to simple_read_from_buffer. Fixes: 14e0e6796a0d ("OMAP: iommu: add initial debugfs support") Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20200714192211.744776-1-colin.king@canonical.com Addresses-Coverity: ("Improper use of negative value") Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/omap-iommu-debug.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c index 505548aafeff2..cec33e90e3998 100644 --- a/drivers/iommu/omap-iommu-debug.c +++ b/drivers/iommu/omap-iommu-debug.c @@ -101,8 +101,11 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf, mutex_lock(&iommu_debug_lock); bytes = omap_iommu_dump_ctx(obj, p, count); + if (bytes < 0) + goto err; bytes = simple_read_from_buffer(userbuf, count, ppos, buf, bytes); +err: mutex_unlock(&iommu_debug_lock); kfree(buf);