diff mbox

[OPW,kernel,1/6] staging: rtl8187se: use memdup_user to simplify code

Message ID 1382645851-928-2-git-send-email-teobaluta@gmail.com
State New, archived
Headers show

Commit Message

Teodora Baluta Oct. 24, 2013, 8:17 p.m. UTC
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>
---
 drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Rusty Russell Oct. 25, 2013, 12:57 a.m. UTC | #1
Teodora Baluta <teobaluta@gmail.com> writes:
> 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>

Nice patch, but again with the extra blank line...

Cheers,
Rusty.

> ---
>  drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c |   12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
> index 0405826..9ff8dab 100644
> --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
> +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
> @@ -2944,14 +2944,10 @@ 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;
>  	}
>  
> -- 
> 1.7.10.4
>
> -- 
> You received this message because you are subscribed to the Google Groups "opw-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to opw-kernel+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
diff mbox

Patch

diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
index 0405826..9ff8dab 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
@@ -2944,14 +2944,10 @@  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;
 	}