public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8192u: remove redundant null check on array alg
@ 2017-02-09 11:06 Colin King
  2018-01-22 15:57 ` [PATCH] staging: rtl8192u: remove redundant initialization of 'timeout' Colin King
  2019-04-04  9:32 ` [PATCH] staging: rtl8192u: remove redundant null check on array 'data' Colin King
  0 siblings, 2 replies; 5+ messages in thread
From: Colin King @ 2017-02-09 11:06 UTC (permalink / raw)
  To: Greg Kroah-Hartman, simran singhal, Bhumika Goyal, Binoy Jayan,
	David S . Miller, Florian Westphal, Amitoj Kaur Chawla,
	Janani Ravichandran, Baoyou Xie, Bhaktipriya Shridhar, devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

u.crypt.alg is an array of u8 integers and hence the null check on
this array is redundant and can be removed.

Detected with CoverityScan, CID#143214 ("Array compared against 0")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 32 ++++++++++------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index 844e257..02b9f7a 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -3056,23 +3056,21 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
 	} else
 		sec.flags &= ~SEC_ACTIVE_KEY;
 
-	if (param->u.crypt.alg != NULL) {
-		memcpy(sec.keys[param->u.crypt.idx],
-		       param->u.crypt.key,
-		       param->u.crypt.key_len);
-		sec.key_sizes[param->u.crypt.idx] = param->u.crypt.key_len;
-		sec.flags |= (1 << param->u.crypt.idx);
-
-		if (strcmp(param->u.crypt.alg, "WEP") = 0) {
-			sec.flags |= SEC_LEVEL;
-			sec.level = SEC_LEVEL_1;
-		} else if (strcmp(param->u.crypt.alg, "TKIP") = 0) {
-			sec.flags |= SEC_LEVEL;
-			sec.level = SEC_LEVEL_2;
-		} else if (strcmp(param->u.crypt.alg, "CCMP") = 0) {
-			sec.flags |= SEC_LEVEL;
-			sec.level = SEC_LEVEL_3;
-		}
+	memcpy(sec.keys[param->u.crypt.idx],
+	       param->u.crypt.key,
+	       param->u.crypt.key_len);
+	sec.key_sizes[param->u.crypt.idx] = param->u.crypt.key_len;
+	sec.flags |= (1 << param->u.crypt.idx);
+
+	if (strcmp(param->u.crypt.alg, "WEP") = 0) {
+		sec.flags |= SEC_LEVEL;
+		sec.level = SEC_LEVEL_1;
+	} else if (strcmp(param->u.crypt.alg, "TKIP") = 0) {
+		sec.flags |= SEC_LEVEL;
+		sec.level = SEC_LEVEL_2;
+	} else if (strcmp(param->u.crypt.alg, "CCMP") = 0) {
+		sec.flags |= SEC_LEVEL;
+		sec.level = SEC_LEVEL_3;
 	}
  done:
 	if (ieee->set_security)
-- 
2.10.2


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

* [PATCH] staging: rtl8192u: remove redundant initialization of 'timeout'
  2017-02-09 11:06 [PATCH] staging: rtl8192u: remove redundant null check on array alg Colin King
@ 2018-01-22 15:57 ` Colin King
  2019-04-04  9:32 ` [PATCH] staging: rtl8192u: remove redundant null check on array 'data' Colin King
  1 sibling, 0 replies; 5+ messages in thread
From: Colin King @ 2018-01-22 15:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, simran singhal, devel; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Variable timeout is initialized however this value is never read and
it is reassigned a new value a little later, hence the initialization
is redundant and can be removed.

Cleans up clang warning:
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:1728:6: warning:
Value stored to 'timeout' during its initialization is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index f56fdc7a4b61..25c186a8bde3 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -1725,7 +1725,7 @@ static void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee,
 static short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h,
 				    u32 *time_l)
 {
-	int timeout = ieee->ps_timeout;
+	int timeout;
 	u8 dtim;
 	/*if(ieee->ps = IEEE80211_PS_DISABLED ||
 		ieee->iw_mode != IW_MODE_INFRA ||
-- 
2.15.1


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

* [PATCH] staging: rtl8192u: remove redundant null check on array 'data'
  2017-02-09 11:06 [PATCH] staging: rtl8192u: remove redundant null check on array alg Colin King
  2018-01-22 15:57 ` [PATCH] staging: rtl8192u: remove redundant initialization of 'timeout' Colin King
@ 2019-04-04  9:32 ` Colin King
  2019-04-04  9:41   ` Dan Carpenter
  2019-04-04 10:28   ` Mukesh Ojha
  1 sibling, 2 replies; 5+ messages in thread
From: Colin King @ 2019-04-04  9:32 UTC (permalink / raw)
  To: Greg Kroah-Hartman, John Whitmore, devel; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The NULL check on ram->u.wpa_ie.data is redudant as data is
zero-length array and is not a pointer, so it can't be null.
Remove the check.

Addresses-Coverity: ("Array compared against 0")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index 944c8894f9ff..c4a4f118f547 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -2659,8 +2659,7 @@ static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee,
 {
 	u8 *buf;
 
-	if (param->u.wpa_ie.len > MAX_WPA_IE_LEN ||
-	    (param->u.wpa_ie.len && param->u.wpa_ie.data = NULL))
+	if (param->u.wpa_ie.len > MAX_WPA_IE_LEN || param->u.wpa_ie.len)
 		return -EINVAL;
 
 	if (param->u.wpa_ie.len) {
-- 
2.20.1

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

* Re: [PATCH] staging: rtl8192u: remove redundant null check on array 'data'
  2019-04-04  9:32 ` [PATCH] staging: rtl8192u: remove redundant null check on array 'data' Colin King
@ 2019-04-04  9:41   ` Dan Carpenter
  2019-04-04 10:28   ` Mukesh Ojha
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2019-04-04  9:41 UTC (permalink / raw)
  To: Colin King
  Cc: Greg Kroah-Hartman, John Whitmore, devel, kernel-janitors,
	linux-kernel

On Thu, Apr 04, 2019 at 10:32:57AM +0100, Colin King wrote:
> diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
> index 944c8894f9ff..c4a4f118f547 100644
> --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
> +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
> @@ -2659,8 +2659,7 @@ static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee,
>  {
>  	u8 *buf;
>  
> -	if (param->u.wpa_ie.len > MAX_WPA_IE_LEN ||
> -	    (param->u.wpa_ie.len && param->u.wpa_ie.data = NULL))
> +	if (param->u.wpa_ie.len > MAX_WPA_IE_LEN || param->u.wpa_ie.len)
>  		return -EINVAL;

Nope...  :P  Don't do that...

regards,
dan carpenter

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

* Re: [PATCH] staging: rtl8192u: remove redundant null check on array 'data'
  2019-04-04  9:32 ` [PATCH] staging: rtl8192u: remove redundant null check on array 'data' Colin King
  2019-04-04  9:41   ` Dan Carpenter
@ 2019-04-04 10:28   ` Mukesh Ojha
  1 sibling, 0 replies; 5+ messages in thread
From: Mukesh Ojha @ 2019-04-04 10:28 UTC (permalink / raw)
  To: Colin King, Greg Kroah-Hartman, John Whitmore, devel
  Cc: kernel-janitors, linux-kernel


On 4/4/2019 3:02 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The NULL check on ram->u.wpa_ie.data is redudant as data is
s/redudant/redundant
> zero-length array and is not a pointer, so it can't be null.
> Remove the check.
>
> Addresses-Coverity: ("Array compared against 0")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

fix the commit text minor err

Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>

Cheers,
-Mukesh

> ---
>   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
> index 944c8894f9ff..c4a4f118f547 100644
> --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
> +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
> @@ -2659,8 +2659,7 @@ static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee,
>   {
>   	u8 *buf;
>   
> -	if (param->u.wpa_ie.len > MAX_WPA_IE_LEN ||
> -	    (param->u.wpa_ie.len && param->u.wpa_ie.data = NULL))
> +	if (param->u.wpa_ie.len > MAX_WPA_IE_LEN || param->u.wpa_ie.len)
>   		return -EINVAL;
>   
>   	if (param->u.wpa_ie.len) {

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

end of thread, other threads:[~2019-04-04 10:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-09 11:06 [PATCH] staging: rtl8192u: remove redundant null check on array alg Colin King
2018-01-22 15:57 ` [PATCH] staging: rtl8192u: remove redundant initialization of 'timeout' Colin King
2019-04-04  9:32 ` [PATCH] staging: rtl8192u: remove redundant null check on array 'data' Colin King
2019-04-04  9:41   ` Dan Carpenter
2019-04-04 10:28   ` Mukesh Ojha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox