Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1241546pxa; Thu, 20 Aug 2020 06:32:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFl730lGQMRBqbeVc5u2k7zp5UiftM7d7DY/8oyTrQrbe+HzJqmTMrWbln3p0VEQnTkfWL X-Received: by 2002:a17:906:aed0:: with SMTP id me16mr3254058ejb.288.1597930374090; Thu, 20 Aug 2020 06:32:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597930374; cv=none; d=google.com; s=arc-20160816; b=eAbHEJSNd5gYLzF1xH9v/lX6YrrPeSf1W/q7GfWo6UNhuxBiB9WwKedy4QO7af0PI8 caXvn0e/q5h4pYtykpLZQAT/ltZZ5H5LS1NMo1nCYEXf5SEC90piN3x3AKeDGKK9153t M4lTSRisFGeSUyGKlgEMKZJNn6Tk8TTH2DCztYi5isLmEnDqsOAeT5lzpxb5aCK3UMwd oFl97Sscm1bARsfNVW7umfTUQD3gwcYTBO81imJHImMkl+2HrmKeT/bLcuGs3vPnFKH/ eWcE1FxK9gHQG4i9S3VIVVncVFNyyIBFWATkQeLx2M3Rn3Jao5+hqv7Sgfuvgv/fYJSt UFWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=h9wvJ3M2gA3QZPI9rSvgx+kznW0BZmtfmJ2Pkn2up8k=; b=CFAFwCU+vE/s9P6XdgUneH6YwhCzTifTWfo/CXfI3ZUqLaWEeqAlwkHNbGhcBBGjnr kZnBGZfQya66f3XTlts3ZOZQWkPqqKbt3YM5SAIbkHtIfF4NYHW2GeAF877UXhiHFOXV z8SKhHeuhFefC87OnQI3QkTP9RYJjC3Wy8/1zYiG7t+uEXmkkMWsiJCRk62wfHgTwyQT nJ8C/SYN500JVlGZ1nruVlBXpjI609rBUweGggr36RKRXJEP9FkslSRLU12Mgua2p9q/ NS5D0jmzsbz+7jNRuZFd3a8cuvdDKU3ir8mht1gSFX8UHfiNtptgBzUY4q/XK6Ga0ODs 259g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E7WC2qoz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si1203261edi.348.2020.08.20.06.32.29; Thu, 20 Aug 2020 06:32:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E7WC2qoz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728593AbgHTNbU (ORCPT + 99 others); Thu, 20 Aug 2020 09:31:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:44430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728325AbgHTJck (ORCPT ); Thu, 20 Aug 2020 05:32:40 -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 7EFFD22B49; Thu, 20 Aug 2020 09:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915960; bh=usJB+l/bgRxFMU7RdfbA4FT6nQW4eTysKwPja/RlPHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E7WC2qozEZbbECcjCSd5JMPA5RuQQ0TRONm8QhrnNJUneA42MGSeJzCFYEikzpqkv IsjydxV7u46LfUKMquTW3ciJ0xxSRLXRTnZngWTAjF2TlKnz6zkTVwW00PwORRpgIK YiKFhL2KefWo17YvGs5hgqM+GYFvN1q7D7qWUpUg= 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 5.8 155/232] iommu/omap: Check for failure of a call to omap_iommu_dump_ctx Date: Thu, 20 Aug 2020 11:20:06 +0200 Message-Id: <20200820091620.319305365@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 8e19bfa94121e..a99afb5d9011c 100644 --- a/drivers/iommu/omap-iommu-debug.c +++ b/drivers/iommu/omap-iommu-debug.c @@ -98,8 +98,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); -- 2.25.1