[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211022025555.6612-1-songkai01@inspur.com>
Date: Fri, 22 Oct 2021 10:55:55 +0800
From: Kai Song <songkai01@...pur.com>
To: <gregkh@...uxfoundation.org>
CC: <Larry.Finger@...inger.net>, <phil@...lpotter.co.uk>,
<straube.linux@...il.com>, <linux-staging@...ts.linux.dev>,
<linux-kernel@...r.kernel.org>, Kai Song <songkai01@...pur.com>
Subject: [PATCH] staging: r8188eu: Use memdup_user instead of kmalloc/copy_from_user
Use memdup_user helper instead of open-coding to simplify
the code.
Signed-off-by: Kai Song <songkai01@...pur.com>
---
drivers/staging/r8188eu/os_dep/ioctl_linux.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
index 0201f6fbeb25..96a08cc5a1ed 100644
--- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
@@ -1984,14 +1984,10 @@ static int rtw_wx_read32(struct net_device *dev,
padapter = (struct adapter *)rtw_netdev_priv(dev);
p = &wrqu->data;
len = p->length;
- ptmp = kmalloc(len, GFP_KERNEL);
- if (!ptmp)
- return -ENOMEM;
- if (copy_from_user(ptmp, p->pointer, len)) {
- kfree(ptmp);
- return -EFAULT;
- }
+ ptmp = memdup_user(p->pointer, len);
+ if (IS_ERR(ptmp))
+ return PTR_ERR(ptmp);
bytes = 0;
addr = 0;
--
2.27.0
Powered by blists - more mailing lists