diff mbox

[OPW,kernel] staging:wlags49_h2:Fix sparse warning incorrect type in assignment

Message ID 20140306201110.GA12848@himangi-Inspiron-N5110gmail.com
State New, archived
Headers show

Commit Message

HIMANGI SARAOGI March 6, 2014, 8:11 p.m. UTC
This patch fixes the sparse warnings :
drivers/staging/wlags49_h2/wl_wext.c:3357:28: warning:
incorrect type in assignment (different address spaces)
drivers/staging/wlags49_h2/wl_wext.c:3357:28:    expected
void [noderef] <asn:1>*[addressable] [assigned] pointer
drivers/staging/wlags49_h2/wl_wext.c:3357:28:    got char
*[usertype] <noident>
drivers/staging/wlags49_h2/wl_wext.c:3422:47: warning:
incorrect type in assignment (different address spaces)
drivers/staging/wlags49_h2/wl_wext.c:3422:47:    expected
void [noderef] <asn:1>*[addressable] [assigned] pointer
drivers/staging/wlags49_h2/wl_wext.c:3422:47:    got char
*[usertype] <noident>

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
---
 drivers/staging/wlags49_h2/wl_wext.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Greg Kroah-Hartman March 6, 2014, 8:17 p.m. UTC | #1
On Fri, Mar 07, 2014 at 01:41:10AM +0530, Himangi Saraogi wrote:
> This patch fixes the sparse warnings :
> drivers/staging/wlags49_h2/wl_wext.c:3357:28: warning:
> incorrect type in assignment (different address spaces)
> drivers/staging/wlags49_h2/wl_wext.c:3357:28:    expected
> void [noderef] <asn:1>*[addressable] [assigned] pointer
> drivers/staging/wlags49_h2/wl_wext.c:3357:28:    got char
> *[usertype] <noident>
> drivers/staging/wlags49_h2/wl_wext.c:3422:47: warning:
> incorrect type in assignment (different address spaces)
> drivers/staging/wlags49_h2/wl_wext.c:3422:47:    expected
> void [noderef] <asn:1>*[addressable] [assigned] pointer
> drivers/staging/wlags49_h2/wl_wext.c:3422:47:    got char
> *[usertype] <noident>

Odd line-wrapping, please put the exact output, as this is really hard
to read.

> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> ---
>  drivers/staging/wlags49_h2/wl_wext.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c
> index 187fc06..8cee409 100644
> --- a/drivers/staging/wlags49_h2/wl_wext.c
> +++ b/drivers/staging/wlags49_h2/wl_wext.c
> @@ -3354,7 +3354,7 @@ void wl_wext_event_essid( struct net_device *dev )
>  	   the call to wireless_send_event() must also point to where the ESSID
>  	   lives */
>  	wrqu.essid.length  = strlen( lp->NetworkName );
> -	wrqu.essid.pointer = (caddr_t)lp->NetworkName;
> +	wrqu.essid.pointer = (caddr_t __user)lp->NetworkName;

Are you sure this is the correct fix?

>  	wrqu.essid.flags   = 1;
>  
>  	wireless_send_event( dev, SIOCSIWESSID, &wrqu, lp->NetworkName );
> @@ -3419,7 +3419,8 @@ void wl_wext_event_encode( struct net_device *dev )
>  
>  		/* Only provide the key if permissions allow */
>  		if( capable( CAP_NET_ADMIN )) {
> -			wrqu.encoding.pointer = (caddr_t)lp->DefaultKeys.key[index].key;
> +			wrqu.encoding.pointer =
> +			    (caddr_t __user)lp->DefaultKeys.key[index].key;

Same here.

thanks,

greg k-h
HIMANGI SARAOGI March 7, 2014, 4:22 p.m. UTC | #2
On Friday, March 7, 2014 1:47:17 AM UTC+5:30, Greg Kroah-Hartman wrote:
>
> On Fri, Mar 07, 2014 at 01:41:10AM +0530, Himangi Saraogi wrote: 
> > This patch fixes the sparse warnings : 
> > drivers/staging/wlags49_h2/wl_wext.c:3357:28: warning: 
> > incorrect type in assignment (different address spaces) 
> > drivers/staging/wlags49_h2/wl_wext.c:3357:28:    expected 
> > void [noderef] <asn:1>*[addressable] [assigned] pointer 
> > drivers/staging/wlags49_h2/wl_wext.c:3357:28:    got char 
> > *[usertype] <noident> 
> > drivers/staging/wlags49_h2/wl_wext.c:3422:47: warning: 
> > incorrect type in assignment (different address spaces) 
> > drivers/staging/wlags49_h2/wl_wext.c:3422:47:    expected 
> > void [noderef] <asn:1>*[addressable] [assigned] pointer 
> > drivers/staging/wlags49_h2/wl_wext.c:3422:47:    got char 
> > *[usertype] <noident> 
>
> Odd line-wrapping, please put the exact output, as this is really hard 
> to read. 
>
> > 
> > Signed-off-by: Himangi Saraogi <himan...@gmail.com <javascript:>> 
> > --- 
> >  drivers/staging/wlags49_h2/wl_wext.c |    5 +++-- 
> >  1 file changed, 3 insertions(+), 2 deletions(-) 
> > 
> > diff --git a/drivers/staging/wlags49_h2/wl_wext.c 
> b/drivers/staging/wlags49_h2/wl_wext.c 
> > index 187fc06..8cee409 100644 
> > --- a/drivers/staging/wlags49_h2/wl_wext.c 
> > +++ b/drivers/staging/wlags49_h2/wl_wext.c 
> > @@ -3354,7 +3354,7 @@ void wl_wext_event_essid( struct net_device *dev ) 
> >             the call to wireless_send_event() must also point to where 
> the ESSID 
> >             lives */ 
> >          wrqu.essid.length  = strlen( lp->NetworkName ); 
> > -        wrqu.essid.pointer = (caddr_t)lp->NetworkName; 
> > +        wrqu.essid.pointer = (caddr_t __user)lp->NetworkName; 
>
> Are you sure this is the correct fix? 
>
The sparse warning says it expected a pointer in the user addressable space 
which cannot
be deferenced. This fix adds __user annotation which has a macro defined 
that  designates 
a pointer as belonging to the user address space, that should not be 
dereferenced. 
So, I think the fix is right. Also, the sparse warnings go away and it 
compiles correctly. Please
correct me if I am wrong.
 

> >          wrqu.essid.flags   = 1; 
> >   
> >          wireless_send_event( dev, SIOCSIWESSID, &wrqu, lp->NetworkName 
> ); 
> > @@ -3419,7 +3419,8 @@ void wl_wext_event_encode( struct net_device *dev 
> ) 
> >   
> >                  /* Only provide the key if permissions allow */ 
> >                  if( capable( CAP_NET_ADMIN )) { 
> > -                        wrqu.encoding.pointer = 
> (caddr_t)lp->DefaultKeys.key[index].key; 
> > +                        wrqu.encoding.pointer = 
> > +                            (caddr_t 
> __user)lp->DefaultKeys.key[index].key; 
>
> Same here. 
>
> thanks, 
>
> greg k-h 
>

Thanks
Himangi
diff mbox

Patch

diff --git a/drivers/staging/wlags49_h2/wl_wext.c b/drivers/staging/wlags49_h2/wl_wext.c
index 187fc06..8cee409 100644
--- a/drivers/staging/wlags49_h2/wl_wext.c
+++ b/drivers/staging/wlags49_h2/wl_wext.c
@@ -3354,7 +3354,7 @@  void wl_wext_event_essid( struct net_device *dev )
 	   the call to wireless_send_event() must also point to where the ESSID
 	   lives */
 	wrqu.essid.length  = strlen( lp->NetworkName );
-	wrqu.essid.pointer = (caddr_t)lp->NetworkName;
+	wrqu.essid.pointer = (caddr_t __user)lp->NetworkName;
 	wrqu.essid.flags   = 1;
 
 	wireless_send_event( dev, SIOCSIWESSID, &wrqu, lp->NetworkName );
@@ -3419,7 +3419,8 @@  void wl_wext_event_encode( struct net_device *dev )
 
 		/* Only provide the key if permissions allow */
 		if( capable( CAP_NET_ADMIN )) {
-			wrqu.encoding.pointer = (caddr_t)lp->DefaultKeys.key[index].key;
+			wrqu.encoding.pointer =
+			    (caddr_t __user)lp->DefaultKeys.key[index].key;
 			wrqu.encoding.length  = lp->DefaultKeys.key[index].len;
 		} else {
 			wrqu.encoding.flags |= IW_ENCODE_NOKEY;