From 216249819ff9fac9ba9f2d06c26194669b42a94a Mon Sep 17 00:00:00 2001 From: Teodora Baluta Date: Sat, 26 Oct 2013 09:18:22 +0300 Subject: [PATCH] staging: rtl8192e: use memdup_user to simplify code Use memdup_user rather than duplicating its implementation. This patch fixes the following coccinelle warnings: drivers/staging/rtl8192e/rtl8192e/rtl_core.c:2598:8-15: WARNING opportunity for memdup_user drivers/staging/rtl8192e/rtllib_softmac.c:3594:9-16: WARNING opportunity for memdup_user Signed-off-by: Teodora Baluta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 11 +++-------- drivers/staging/rtl8192e/rtllib_softmac.c | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 6ba02fcd57da..bd8c9a2970fc 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -2593,14 +2593,9 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) goto out; } - ipw = kmalloc(p->length, GFP_KERNEL); - if (ipw == NULL) { - ret = -ENOMEM; - goto out; - } - if (copy_from_user(ipw, p->pointer, p->length)) { - kfree(ipw); - ret = -EFAULT; + ipw = memdup_user(p->pointer, p->length); + if (IS_ERR(ipw)) { + ret = PTR_ERR(ipw); goto out; } diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index e74d24212a39..671fb5ac5744 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -3590,14 +3590,9 @@ int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p, goto out; } - param = kmalloc(p->length, GFP_KERNEL); - if (param == NULL) { - ret = -ENOMEM; - goto out; - } - if (copy_from_user(param, p->pointer, p->length)) { - kfree(param); - ret = -EFAULT; + param = memdup_user(p->pointer, p->length); + if (IS_ERR(param)) { + ret = PTR_ERR(param); goto out; } -- 2.30.2