lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <1603873791-106258-1-git-send-email-zou_wei@huawei.com>
Date:   Wed, 28 Oct 2020 16:29:51 +0800
From:   Zou Wei <zou_wei@...wei.com>
To:     <thierry.reding@...il.com>, <jonathanh@...dia.com>
CC:     <linux-tegra@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        Zou Wei <zou_wei@...wei.com>
Subject: [PATCH -next] firmware: tegra: Use memdup_user() as a cleanup

Fix coccicheck warning which recommends to use memdup_user().

This patch fixes the following coccicheck warning:

./drivers/firmware/tegra/bpmp-debugfs.c:335:11-18: WARNING opportunity for memdup_user

Fixes: 5e37b9c137ee ("firmware: tegra: Add support for in-band debug")
Reported-by: Hulk Robot <hulkci@...wei.com>
Signed-off-by: Zou Wei <zou_wei@...wei.com>
---
 drivers/firmware/tegra/bpmp-debugfs.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/tegra/bpmp-debugfs.c b/drivers/firmware/tegra/bpmp-debugfs.c
index c1bbba9..7234136 100644
--- a/drivers/firmware/tegra/bpmp-debugfs.c
+++ b/drivers/firmware/tegra/bpmp-debugfs.c
@@ -332,12 +332,9 @@ static ssize_t bpmp_debug_store(struct file *file, const char __user *buf,
 	if (!filename)
 		return -ENOENT;
 
-	databuf = kmalloc(count, GFP_KERNEL);
-	if (!databuf)
-		return -ENOMEM;
-
-	if (copy_from_user(databuf, buf, count)) {
-		err = -EFAULT;
+	databuf = memdup_user(buf, count);
+	if (IS_ERR(databuf)) {
+		err = PTR_ERR(databuf);
 		goto free_ret;
 	}
 
-- 
2.6.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ