Fix following coccicheck warning: ./drivers/staging/r8188eu/os_dep/ioctl_linux.c:1986:8-15: WARNING opportunity for memdup_user. Use memdup_user rather than duplicating its implementation, which makes code simple and easy to understand. Signed-off-by: Wan Jiabing <wanjiabing@xxxxxxxx> --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 4f0ae821d193..301a29984fad 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -1983,14 +1983,9 @@ 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.20.1