linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* re: Added Realtek rtl8192u driver to staging - static analysis report.
@ 2019-08-21 18:18 Colin Ian King
  2019-08-21 20:55 ` Greg Kroah-Hartman
  2019-08-22  8:08 ` Dan Carpenter
  0 siblings, 2 replies; 4+ messages in thread
From: Colin Ian King @ 2019-08-21 18:18 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jerry Chuang, John Whitmore, devel; +Cc: linux-kernel

Hi,

Static analysis of linux-next picked up an issue with the following commit:

commit 8fc8598e61f6f384f3eaf1d9b09500c12af47b37
Author: Jerry Chuang <jerry-chuang@realtek.com>
Date:   Tue Nov 3 07:17:11 2009 -0200

    Staging: Added Realtek rtl8192u driver to staging

In drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c we have:

CID 48331 (#1 of 1): Unused value (UNUSED_VALUE) assigned_pointer

Assigning value from ieee->crypt[ieee->tx_keyidx] to crypt here, but
that stored value is not used.

746        crypt = ieee->crypt[ieee->tx_keyidx];
747        if (encrypt)
748                beacon_buf->capability |=
cpu_to_le16(WLAN_CAPABILITY_PRIVACY);

Pointer crypt is being assigned but is never used afterwards.  Now
either this is a redundant assignment and can be removed OR maybe crypt
should be checked and there is a typo, e.g.:

	crypt = ieee->crypt[ieee->tx_keyidx];
	if (crypt)
		...

Either way, it's not clear to me and I think the code needs cleaning up.
Any ideas?

Colin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Added Realtek rtl8192u driver to staging - static analysis report.
  2019-08-21 18:18 Added Realtek rtl8192u driver to staging - static analysis report Colin Ian King
@ 2019-08-21 20:55 ` Greg Kroah-Hartman
  2019-08-21 21:56   ` stephen
  2019-08-22  8:08 ` Dan Carpenter
  1 sibling, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-08-21 20:55 UTC (permalink / raw)
  To: Colin Ian King; +Cc: Jerry Chuang, John Whitmore, devel, linux-kernel

On Wed, Aug 21, 2019 at 07:18:39PM +0100, Colin Ian King wrote:
> Hi,
> 
> Static analysis of linux-next picked up an issue with the following commit:
> 
> commit 8fc8598e61f6f384f3eaf1d9b09500c12af47b37
> Author: Jerry Chuang <jerry-chuang@realtek.com>
> Date:   Tue Nov 3 07:17:11 2009 -0200
> 
>     Staging: Added Realtek rtl8192u driver to staging
> 
> In drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c we have:
> 
> CID 48331 (#1 of 1): Unused value (UNUSED_VALUE) assigned_pointer
> 
> Assigning value from ieee->crypt[ieee->tx_keyidx] to crypt here, but
> that stored value is not used.
> 
> 746        crypt = ieee->crypt[ieee->tx_keyidx];
> 747        if (encrypt)
> 748                beacon_buf->capability |=
> cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
> 
> Pointer crypt is being assigned but is never used afterwards.  Now
> either this is a redundant assignment and can be removed OR maybe crypt
> should be checked and there is a typo, e.g.:
> 
> 	crypt = ieee->crypt[ieee->tx_keyidx];
> 	if (crypt)
> 		...
> 
> Either way, it's not clear to me and I think the code needs cleaning up.
> Any ideas?

10+ year old code, yeah!!!

Just guess, who knows, no one seems to care :(

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Added Realtek rtl8192u driver to staging - static analysis report.
  2019-08-21 20:55 ` Greg Kroah-Hartman
@ 2019-08-21 21:56   ` stephen
  0 siblings, 0 replies; 4+ messages in thread
From: stephen @ 2019-08-21 21:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Colin Ian King, devel, Jerry Chuang, linux-kernel, John Whitmore

> > Either way, it's not clear to me and I think the code needs cleaning 
> > up.
> > Any ideas?
> 
> 10+ year old code, yeah!!!
> 
> Just guess, who knows, no one seems to care :(

I'm at least interested in helping with cleaning the code and learning 
about the driver, maybe fixing up logical errors like this at some point.  
But I have had some trouble finding the hardware to test on. Maybe that's 
part of the issue?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Added Realtek rtl8192u driver to staging - static analysis report.
  2019-08-21 18:18 Added Realtek rtl8192u driver to staging - static analysis report Colin Ian King
  2019-08-21 20:55 ` Greg Kroah-Hartman
@ 2019-08-22  8:08 ` Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2019-08-22  8:08 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Greg Kroah-Hartman, Jerry Chuang, John Whitmore, devel, linux-kernel

On Wed, Aug 21, 2019 at 07:18:39PM +0100, Colin Ian King wrote:
> Hi,
> 
> Static analysis of linux-next picked up an issue with the following commit:
> 
> commit 8fc8598e61f6f384f3eaf1d9b09500c12af47b37
> Author: Jerry Chuang <jerry-chuang@realtek.com>
> Date:   Tue Nov 3 07:17:11 2009 -0200
> 
>     Staging: Added Realtek rtl8192u driver to staging
> 
> In drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c we have:
> 
> CID 48331 (#1 of 1): Unused value (UNUSED_VALUE) assigned_pointer
> 
> Assigning value from ieee->crypt[ieee->tx_keyidx] to crypt here, but
> that stored value is not used.
> 
> 746        crypt = ieee->crypt[ieee->tx_keyidx];
> 747        if (encrypt)
> 748                beacon_buf->capability |=
> cpu_to_le16(WLAN_CAPABILITY_PRIVACY);

Earlir in the function we have:

   695          crypt = ieee->crypt[ieee->tx_keyidx];
   696  
   697          encrypt = ieee->host_encrypt && crypt && crypt->ops &&
   698                  ((0 == strcmp(crypt->ops->name, "WEP") || wpa_ie_len));
   699          /* HT ralated element */

So the "crypt" assignment is dublicate and should definitely be removed.
The "if (encrypt) " check looks correct and it sort of matches what we
do in ieee80211_assoc_resp().

   840          encrypt = crypt && crypt->ops;
   841  
   842          if (encrypt)
   843                  assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
   844  

So let's leave it as-is, just delete the crypt assignment.  If you want,
you can send this patch and I can give you a Reviewed-by tag or if you
want I can send the patch and give you Reported-by credit.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-22  8:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-21 18:18 Added Realtek rtl8192u driver to staging - static analysis report Colin Ian King
2019-08-21 20:55 ` Greg Kroah-Hartman
2019-08-21 21:56   ` stephen
2019-08-22  8:08 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).