staging: rtl8187se: use memdup_user to simplify code
authorTeodora Baluta <teobaluta@gmail.com>
Fri, 25 Oct 2013 09:00:14 +0000 (12:00 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Oct 2013 21:34:42 +0000 (14:34 -0700)
This patch fixes the following coccinelle warning to use memdup_user
rather than duplicating its implementation:

drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c:2947:9-16: WARNING opportunity for memdup_user

Signed-off-by: Teodora Baluta <teobaluta@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c

index 04058263398e600bb1d416393f4989566b3bb46d..029070603f661861d9081b374b47ffb6873fd0b8 100644 (file)
@@ -2944,14 +2944,9 @@ int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_poin
                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;
        }