Use memdup_user helper instead of open-coding to simplify the code. Signed-off-by: Kai Song <songkai01@xxxxxxxxxx> --- 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