[PATCH] mwifiex: mark expected switch fall-throughs

2018-05-25 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/net/wireless/marvell/mwifiex/cfg80211.c | 4 
 drivers/net/wireless/marvell/mwifiex/scan.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c 
b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index 54a2297..16a705d 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -1158,6 +1158,7 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
case NL80211_IFTYPE_UNSPECIFIED:
mwifiex_dbg(priv->adapter, INFO,
"%s: kept type as IBSS\n", dev->name);
+   /* fall through */
case NL80211_IFTYPE_ADHOC:  /* This shouldn't happen */
return 0;
default:
@@ -1188,6 +1189,7 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
case NL80211_IFTYPE_UNSPECIFIED:
mwifiex_dbg(priv->adapter, INFO,
"%s: kept type as STA\n", dev->name);
+   /* fall through */
case NL80211_IFTYPE_STATION:/* This shouldn't happen */
return 0;
default:
@@ -1210,6 +1212,7 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
case NL80211_IFTYPE_UNSPECIFIED:
mwifiex_dbg(priv->adapter, INFO,
"%s: kept type as AP\n", dev->name);
+   /* fall through */
case NL80211_IFTYPE_AP: /* This shouldn't happen */
return 0;
default:
@@ -1249,6 +1252,7 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
case NL80211_IFTYPE_UNSPECIFIED:
mwifiex_dbg(priv->adapter, INFO,
"%s: kept type as P2P\n", dev->name);
+   /* fall through */
case NL80211_IFTYPE_P2P_CLIENT:
case NL80211_IFTYPE_P2P_GO:
return 0;
diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c 
b/drivers/net/wireless/marvell/mwifiex/scan.c
index d7ce7f7..19df92b 100644
--- a/drivers/net/wireless/marvell/mwifiex/scan.c
+++ b/drivers/net/wireless/marvell/mwifiex/scan.c
@@ -1308,6 +1308,7 @@ int mwifiex_update_bss_desc_with_ie(struct 
mwifiex_adapter *adapter,
 
case WLAN_EID_CHANNEL_SWITCH:
bss_entry->chan_sw_ie_present = true;
+   /* fall through */
case WLAN_EID_PWR_CAPABILITY:
case WLAN_EID_TPC_REPORT:
case WLAN_EID_QUIET:
-- 
2.7.4



[PATCH] ath9k: mark expected switch fall-throughs

2018-05-25 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/net/wireless/ath/ath9k/ar5008_phy.c | 2 ++
 drivers/net/wireless/ath/ath9k/ar9002_phy.c | 1 +
 drivers/net/wireless/ath/ath9k/main.c   | 1 +
 3 files changed, 4 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c 
b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
index 7922550..ef2dd68 100644
--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
@@ -583,12 +583,14 @@ static void ar5008_hw_init_chain_masks(struct ath_hw *ah)
case 0x5:
REG_SET_BIT(ah, AR_PHY_ANALOG_SWAP,
AR_PHY_SWAP_ALT_CHAIN);
+   /* fall through */
case 0x3:
if (ah->hw_version.macVersion == AR_SREV_REVISION_5416_10) {
REG_WRITE(ah, AR_PHY_RX_CHAINMASK, 0x7);
REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, 0x7);
break;
}
+   /* else: fall through */
case 0x1:
case 0x2:
case 0x7:
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_phy.c 
b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
index 61a9b85..7132918 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_phy.c
@@ -119,6 +119,7 @@ static int ar9002_hw_set_channel(struct ath_hw *ah, struct 
ath9k_channel *chan)
aModeRefSel = 2;
if (aModeRefSel)
break;
+   /* else: fall through */
case 1:
default:
aModeRefSel = 0;
diff --git a/drivers/net/wireless/ath/ath9k/main.c 
b/drivers/net/wireless/ath/ath9k/main.c
index a3be8ad..11d84f4 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1928,6 +1928,7 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw,
case IEEE80211_AMPDU_TX_STOP_FLUSH:
case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
flush = true;
+   /* fall through */
case IEEE80211_AMPDU_TX_STOP_CONT:
ath9k_ps_wakeup(sc);
ath_tx_aggr_stop(sc, sta, tid);
-- 
2.7.4



Re: [PATCH v2] ath6kl: mark expected switch fall-throughs

2018-05-25 Thread Gustavo A. R. Silva



On 05/25/2018 01:27 PM, Steve deRosier wrote:

On Fri, May 25, 2018 at 11:23 AM Gustavo A. R. Silva
<gust...@embeddedor.com>
wrote:


In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.



Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
Changes in v2:
- Place code comments on a line of their own.



drivers/net/wireless/ath/ath6kl/cfg80211.c | 3 +++
1 file changed, 3 insertions(+)



diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c

b/drivers/net/wireless/ath/ath6kl/cfg80211.c

index 2ba8cf3..a16ee5d 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -3899,16 +3899,19 @@ int ath6kl_cfg80211_init(struct ath6kl *ar)
   switch (ar->hw.cap) {
   case WMI_11AN_CAP:
   ht = true;
+   /* fall through */
   case WMI_11A_CAP:
   band_5gig = true;
   break;
   case WMI_11GN_CAP:
   ht = true;
+   /* fall through */
   case WMI_11G_CAP:
   band_2gig = true;
   break;
   case WMI_11AGN_CAP:
   ht = true;
+   /* fall through */
   case WMI_11AG_CAP:
   band_2gig = true;
   band_5gig = true;
--
2.7.4



Gustavo,

Thanks for the adjustment.  It now looks good to me.



Glad to help. :)


Reviewed-by: Steve deRosier <deros...@cal-sierra.com>


Thanks
--
Gustavo


Re: [PATCH] ath6kl: mark expected switch fall-throughs

2018-05-25 Thread Gustavo A. R. Silva



On 05/25/2018 01:10 PM, Kalle Valo wrote:

Yeah, I was wondering the same. Was there a particular reason for this?



Sometimes people use this style for a one-line code block.

I can change it to the traditional style. No problem.


I would prefer that. So if you can send v2 that would be great.



Yep. No problem. I'll send it shortly.

Thanks
--
Gustavo


[PATCH v2] ath6kl: mark expected switch fall-throughs

2018-05-25 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
Changes in v2:
 - Place code comments on a line of their own.

 drivers/net/wireless/ath/ath6kl/cfg80211.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c 
b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index 2ba8cf3..a16ee5d 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -3899,16 +3899,19 @@ int ath6kl_cfg80211_init(struct ath6kl *ar)
switch (ar->hw.cap) {
case WMI_11AN_CAP:
ht = true;
+   /* fall through */
case WMI_11A_CAP:
band_5gig = true;
break;
case WMI_11GN_CAP:
ht = true;
+   /* fall through */
case WMI_11G_CAP:
band_2gig = true;
break;
case WMI_11AGN_CAP:
ht = true;
+   /* fall through */
case WMI_11AG_CAP:
band_2gig = true;
band_5gig = true;
-- 
2.7.4



Re: [PATCH] ath6kl: mark expected switch fall-throughs

2018-05-25 Thread Gustavo A. R. Silva



On 05/25/2018 08:30 AM, Kalle Valo wrote:

Sergei Shtylyov <sergei.shtyl...@cogentembedded.com> writes:


On 5/25/2018 2:13 AM, Gustavo A. R. Silva wrote:


In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
   drivers/net/wireless/ath/ath6kl/cfg80211.c | 6 +++---
   1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c 
b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index 2ba8cf3..29e32cd 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -3898,17 +3898,17 @@ int ath6kl_cfg80211_init(struct ath6kl *ar)
wiphy->max_scan_ie_len = 1000; /* FIX: what is correct limit? */
switch (ar->hw.cap) {
case WMI_11AN_CAP:
-   ht = true;
+   ht = true; /* fall through */
case WMI_11A_CAP:
band_5gig = true;
break;
case WMI_11GN_CAP:
-   ht = true;
+   ht = true; /* fall through */
case WMI_11G_CAP:
band_2gig = true;
break;
case WMI_11AGN_CAP:
-   ht = true;
+   ht = true; /* fall through */
case WMI_11AG_CAP:
band_2gig = true;
band_5gig = true;


Hm, typically such comments are done on a line of their own, have
never seen this style...


Yeah, I was wondering the same. Was there a particular reason for this?



Sometimes people use this style for a one-line code block.

I can change it to the traditional style. No problem.

Thanks
--
Gustavo


[PATCH] ath5k: mark expected switch fall-through

2018-05-24 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/net/wireless/ath/ath5k/pcu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ath/ath5k/pcu.c 
b/drivers/net/wireless/ath/ath5k/pcu.c
index f23c851..05140d8 100644
--- a/drivers/net/wireless/ath/ath5k/pcu.c
+++ b/drivers/net/wireless/ath/ath5k/pcu.c
@@ -670,6 +670,7 @@ ath5k_hw_init_beacon_timers(struct ath5k_hw *ah, u32 
next_beacon, u32 interval)
break;
case NL80211_IFTYPE_ADHOC:
AR5K_REG_ENABLE_BITS(ah, AR5K_TXCFG, AR5K_TXCFG_ADHOC_BCN_ATIM);
+   /* fall through */
default:
/* On non-STA modes timer1 is used as next DMA
 * beacon alert (DBA) timer and timer2 as next
-- 
2.7.4



[PATCH] ath10k: htt_tx: mark expected switch fall-throughs

2018-05-24 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Notice that in this particular case, I replaced "pass through" with
a proper "fall through" comment, which is what GCC is expecting
to find.

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/net/wireless/ath/ath10k/htt_tx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c 
b/drivers/net/wireless/ath/ath10k/htt_tx.c
index 5d8b97a..89157c5 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -1202,7 +1202,7 @@ static int ath10k_htt_tx_32(struct ath10k_htt *htt,
case ATH10K_HW_TXRX_RAW:
case ATH10K_HW_TXRX_NATIVE_WIFI:
flags0 |= HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT;
-   /* pass through */
+   /* fall through */
case ATH10K_HW_TXRX_ETHERNET:
if (ar->hw_params.continuous_frag_desc) {
ext_desc_t = htt->frag_desc.vaddr_desc_32;
@@ -1404,7 +1404,7 @@ static int ath10k_htt_tx_64(struct ath10k_htt *htt,
case ATH10K_HW_TXRX_RAW:
case ATH10K_HW_TXRX_NATIVE_WIFI:
flags0 |= HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT;
-   /* pass through */
+   /* fall through */
case ATH10K_HW_TXRX_ETHERNET:
if (ar->hw_params.continuous_frag_desc) {
ext_desc_t = htt->frag_desc.vaddr_desc_64;
-- 
2.7.4



[PATCH] ath6kl: mark expected switch fall-throughs

2018-05-24 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/net/wireless/ath/ath6kl/cfg80211.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c 
b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index 2ba8cf3..29e32cd 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -3898,17 +3898,17 @@ int ath6kl_cfg80211_init(struct ath6kl *ar)
wiphy->max_scan_ie_len = 1000; /* FIX: what is correct limit? */
switch (ar->hw.cap) {
case WMI_11AN_CAP:
-   ht = true;
+   ht = true; /* fall through */
case WMI_11A_CAP:
band_5gig = true;
break;
case WMI_11GN_CAP:
-   ht = true;
+   ht = true; /* fall through */
case WMI_11G_CAP:
band_2gig = true;
break;
case WMI_11AGN_CAP:
-   ht = true;
+   ht = true; /* fall through */
case WMI_11AG_CAP:
band_2gig = true;
band_5gig = true;
-- 
2.7.4



Re: [PATCH] rtlwifi: remove duplicate code

2018-05-24 Thread Gustavo A. R. Silva

Hi Joe,

On 05/24/2018 02:24 PM, Joe Perches wrote:

On Thu, 2018-05-24 at 13:54 -0500, Gustavo A. R. Silva wrote:

Remove and refactor some code in order to avoid having identical code
for different branches.


True and nice tool and patch submittal thanks.


Notice that the logic has been there since 2014.


But perhaps the original logic is a defective copy/paste
and it should be corrected instead.

Can anyone from realtek verify this?



I actually used gitk to track down the last changes made to this code 
and, it doesn't look like a copy/paste issue:


commit: c6821613e653aae4f54c75689e229e3f063b7f69
commit: 27a31a60a4de4c1b45e371152bb6e701e1a8cc40

Thanks
--
Gustavo


Addresses-Coverity-ID: 1426199 ("Identical code for different branches")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
  .../realtek/rtlwifi/btcoexist/halbtc8723b2ant.c| 23 --
  1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index 279fe01..df3facc 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -2876,25 +2876,10 @@ static void btc8723b2ant_action_hid(struct btc_coexist 
*btcoexist)
btc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13);
  
  	/* sw mechanism */

-   if (BTC_WIFI_BW_HT40 == wifi_bw) {
-   if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
-   (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
-   btc8723b2ant_sw_mechanism(btcoexist, true, true,
- false, false);
-   } else {
-   btc8723b2ant_sw_mechanism(btcoexist, true, true,
- false, false);
-   }
-   } else {
-   if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
-   (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
-   btc8723b2ant_sw_mechanism(btcoexist, false, true,
- false, false);
-   } else {
-   btc8723b2ant_sw_mechanism(btcoexist, false, true,
- false, false);
-   }
-   }
+   if (wifi_bw == BTC_WIFI_BW_HT40)
+   btc8723b2ant_sw_mechanism(btcoexist, true, true, false, false);
+   else
+   btc8723b2ant_sw_mechanism(btcoexist, false, true, false, false);
  }
  
  /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */


[PATCH] rtlwifi: remove duplicate code

2018-05-24 Thread Gustavo A. R. Silva
Remove and refactor some code in order to avoid having identical code
for different branches.

Notice that the logic has been there since 2014.

Addresses-Coverity-ID: 1426199 ("Identical code for different branches")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 .../realtek/rtlwifi/btcoexist/halbtc8723b2ant.c| 23 --
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
index 279fe01..df3facc 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b2ant.c
@@ -2876,25 +2876,10 @@ static void btc8723b2ant_action_hid(struct btc_coexist 
*btcoexist)
btc8723b2ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13);
 
/* sw mechanism */
-   if (BTC_WIFI_BW_HT40 == wifi_bw) {
-   if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
-   (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
-   btc8723b2ant_sw_mechanism(btcoexist, true, true,
- false, false);
-   } else {
-   btc8723b2ant_sw_mechanism(btcoexist, true, true,
- false, false);
-   }
-   } else {
-   if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
-   (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) {
-   btc8723b2ant_sw_mechanism(btcoexist, false, true,
- false, false);
-   } else {
-   btc8723b2ant_sw_mechanism(btcoexist, false, true,
- false, false);
-   }
-   }
+   if (wifi_bw == BTC_WIFI_BW_HT40)
+   btc8723b2ant_sw_mechanism(btcoexist, true, true, false, false);
+   else
+   btc8723b2ant_sw_mechanism(btcoexist, false, true, false, false);
 }
 
 /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
-- 
2.7.4



[PATCH] staging: wilc1000: fix infinite loop and out-of-bounds access

2018-04-30 Thread Gustavo A. R. Silva
If i < slot_id is initially true then it will remain true. Also,
as i is being decremented it will end up accessing memory out of
bounds.

Fix this by incrementing *i* instead of decrementing it.

Addresses-Coverity-ID: 1468454 ("Infinite loop")
Fixes: faa657641081 ("staging: wilc1000: refactor scan() to free kmalloc
memory on failure cases")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---

BTW... at first sight it seems to me that variables slot_id
and i should be of type unsigned instead of signed.

 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 3ca0c97..67104e8 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -608,7 +608,7 @@ wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request 
*request,
 
 out_free:
 
-   for (i = 0; i < slot_id ; i--)
+   for (i = 0; i < slot_id; i++)
kfree(ntwk->net_info[i].ssid);
 
kfree(ntwk->net_info);
-- 
2.7.4



Re: [PATCH] rsi: fix a bug in rsi_hal_key_config()

2018-04-27 Thread Gustavo A. R. Silva

Hi Dan,

On 04/27/2018 06:44 AM, Dan Carpenter wrote:

On Fri, Apr 27, 2018 at 02:32:20PM +0300, Kalle Valo wrote:


Gustavo submitted an identical patch also for this one :)

https://patchwork.kernel.org/patch/10365997/



Hey Gustavo,

We keep on sending duplicate patches.  Most of the static checker people
CC kernel-janit...@vger.kernel.org so we can see what's already been
sent.



Oh, I didn't know that.  I'll start CCing that list then.

Thanks for letting me know.
--
Gustavo


[PATCH] rsi_91x_mac80211: fix structurally dead code

2018-04-26 Thread Gustavo A. R. Silva
Function rsi_hal_key_config returns before reaching code at line
922 if (status), hence this code is structurally dead.

Fix this by storing the value returned by rsi_hal_load_key
into _status_ for its further evaluation and use.

Addresses-Coverity-ID: 1468409 ("Structurally dead code")
Fixes: 4fd6c4762f37 ("rsi: roaming enhancements")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/net/wireless/rsi/rsi_91x_mac80211.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c 
b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
index 766d874..80e7f4f 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
@@ -911,14 +911,14 @@ static int rsi_hal_key_config(struct ieee80211_hw *hw,
}
}
 
-   return rsi_hal_load_key(adapter->priv,
-   key->key,
-   key->keylen,
-   key_type,
-   key->keyidx,
-   key->cipher,
-   sta_id,
-   vif);
+   status = rsi_hal_load_key(adapter->priv,
+ key->key,
+ key->keylen,
+ key_type,
+ key->keyidx,
+ key->cipher,
+ sta_id,
+ vif);
if (status)
return status;
 
-- 
2.7.4



[PATCH] rsi_91x_usb: fix uninitialized variable

2018-04-26 Thread Gustavo A. R. Silva
There is a potential execution path in which variable ret is returned
without being properly initialized previously.

Fix this by storing the value returned by function
rsi_usb_master_reg_write into _ret_.

Addresses-Coverity-ID: 1468407 ("Uninitialized scalar variable")
Fixes: 16d3bb7b2f37 ("rsi: disable fw watchdog timer during reset")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/net/wireless/rsi/rsi_91x_usb.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c 
b/drivers/net/wireless/rsi/rsi_91x_usb.c
index b065438..6ce6b75 100644
--- a/drivers/net/wireless/rsi/rsi_91x_usb.c
+++ b/drivers/net/wireless/rsi/rsi_91x_usb.c
@@ -687,9 +687,10 @@ static int rsi_reset_card(struct rsi_hw *adapter)
 */
msleep(100);
 
-   if (rsi_usb_master_reg_write(adapter, SWBL_REGOUT,
-RSI_FW_WDT_DISABLE_REQ,
-RSI_COMMON_REG_SIZE) < 0) {
+   ret = rsi_usb_master_reg_write(adapter, SWBL_REGOUT,
+  RSI_FW_WDT_DISABLE_REQ,
+  RSI_COMMON_REG_SIZE);
+   if (ret < 0) {
rsi_dbg(ERR_ZONE, "Disabling firmware watchdog timer failed\n");
goto fail;
}
-- 
2.7.4



Re: [PATCH] qtnfmac: pearl: pcie: fix memory leak in qtnf_fw_work_handler

2018-04-05 Thread Gustavo A. R. Silva

Hi Sergey,

On 04/05/2018 11:31 AM, Sergey Matyukevich wrote:

Hello Gustavo,


In case memory resources for fw were succesfully allocated, release
them before jumping to fw_load_fail.

Addresses-Coverity-ID: 1466092 ("Resource leak")
Fixes: c3b2f7ca4186 ("qtnfmac: implement asynchronous firmware loading")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
  drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c | 4 
  1 file changed, 4 insertions(+)


Thanks for the patch!



Glad to help. :)


Reviewed-by: Sergey Matyukevich <sergey.matyukevich...@quantenna.com>



Thanks
--
Gustavo



[PATCH] qtnfmac: pearl: pcie: fix memory leak in qtnf_fw_work_handler

2018-04-05 Thread Gustavo A. R. Silva
In case memory resources for fw were succesfully allocated, release
them before jumping to fw_load_fail.

Addresses-Coverity-ID: 1466092 ("Resource leak")
Fixes: c3b2f7ca4186 ("qtnfmac: implement asynchronous firmware loading")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c 
b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
index f117904..6c1e139 100644
--- a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
+++ b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
@@ -1185,6 +1185,10 @@ static void qtnf_fw_work_handler(struct work_struct 
*work)
if (qtnf_poll_state(>bda->bda_ep_state, QTN_EP_FW_LOADRDY,
QTN_FW_DL_TIMEOUT_MS)) {
pr_err("card is not ready\n");
+
+   if (!flashboot)
+   release_firmware(fw);
+
goto fw_load_fail;
}
 
-- 
2.7.4



[rtlwifi-btcoex] Suspicious code in halbtc8821a1ant driver

2018-04-04 Thread Gustavo A. R. Silva
Hi all,

While doing some static analysis I came across the following piece of code at 
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.c:1581:

1581 static void btc8821a1ant_act_bt_sco_hid_only_busy(struct btc_coexist 
*btcoexist,
1582   u8 wifi_status)
1583 {
1584 /* tdma and coex table */
1585 btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
1586 
1587 if (BT_8821A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN ==
1588 wifi_status)
1589 btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 
1);
1590 else
1591 btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 
1);
1592 }

The issue here is that the code for both branches of the if-else statement is 
identical.

The if-else was introduced a year ago in this commit c6821613e653

I wonder if an argument should be changed in any of the calls to 
btc8821a1ant_coex_table_with_type?

What do you think?

Thanks
--
Gustavo


[PATCH] brcm80211: brcmsmac: phy_lcn: remove duplicate code

2018-04-04 Thread Gustavo A. R. Silva
Remove and refactor some code in order to avoid having identical code
for different branches.

Notice that this piece of code hasn't been modified since 2011.

Addresses-Coverity-ID: 1226756 ("Identical code for different branches")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
index 93d4cde..9d830d2 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
@@ -3388,13 +3388,8 @@ void wlc_lcnphy_deaf_mode(struct brcms_phy *pi, bool 
mode)
u8 phybw40;
phybw40 = CHSPEC_IS40(pi->radio_chanspec);
 
-   if (LCNREV_LT(pi->pubpi.phy_rev, 2)) {
-   mod_phy_reg(pi, 0x4b0, (0x1 << 5), (mode) << 5);
-   mod_phy_reg(pi, 0x4b1, (0x1 << 9), 0 << 9);
-   } else {
-   mod_phy_reg(pi, 0x4b0, (0x1 << 5), (mode) << 5);
-   mod_phy_reg(pi, 0x4b1, (0x1 << 9), 0 << 9);
-   }
+   mod_phy_reg(pi, 0x4b0, (0x1 << 5), (mode) << 5);
+   mod_phy_reg(pi, 0x4b1, (0x1 << 9), 0 << 9);
 
if (phybw40 == 0) {
mod_phy_reg((pi), 0x410,
-- 
2.7.4



[PATCH] mt7601u: phy: mark expected switch fall-through

2018-03-30 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/net/wireless/mediatek/mt7601u/phy.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/mediatek/mt7601u/phy.c 
b/drivers/net/wireless/mediatek/mt7601u/phy.c
index ca09a5d..9a90f1f 100644
--- a/drivers/net/wireless/mediatek/mt7601u/phy.c
+++ b/drivers/net/wireless/mediatek/mt7601u/phy.c
@@ -795,6 +795,7 @@ mt7601u_phy_rf_pa_mode_val(struct mt7601u_dev *dev, int 
phy_mode, int tx_rate)
switch (phy_mode) {
case MT_PHY_TYPE_OFDM:
tx_rate += 4;
+   /* fall through */
case MT_PHY_TYPE_CCK:
reg = dev->rf_pa_mode[0];
break;
-- 
2.7.4



[PATCH] ath9k: dfs: remove accidental use of stack VLA

2018-03-30 Thread Gustavo A. R. Silva
In preparation to enabling -Wvla, remove accidental use of stack VLA.

This avoids an accidental stack VLA (since the compiler thinks
the value of FFT_NUM_SAMPLES can change, even when marked
"const"). This just replaces it with a #define.

Also, fixed as part of the directive to remove all VLAs from
the kernel: https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/net/wireless/ath/ath9k/dfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/dfs.c 
b/drivers/net/wireless/ath/ath9k/dfs.c
index 6fee9a4..c8844f5 100644
--- a/drivers/net/wireless/ath/ath9k/dfs.c
+++ b/drivers/net/wireless/ath/ath9k/dfs.c
@@ -41,7 +41,7 @@ static const int BIN_DELTA_MAX= 10;
 
 /* we need at least 3 deltas / 4 samples for a reliable chirp detection */
 #define NUM_DIFFS 3
-static const int FFT_NUM_SAMPLES   = (NUM_DIFFS + 1);
+#define FFT_NUM_SAMPLES(NUM_DIFFS + 1)
 
 /* Threshold for difference of delta peaks */
 static const int MAX_DIFF  = 2;
@@ -114,7 +114,7 @@ static bool ath9k_check_chirping(struct ath_softc *sc, u8 
*data,
 
ath_dbg(common, DFS, "HT40: datalen=%d, num_fft_packets=%d\n",
datalen, num_fft_packets);
-   if (num_fft_packets < (FFT_NUM_SAMPLES)) {
+   if (num_fft_packets < FFT_NUM_SAMPLES) {
ath_dbg(common, DFS, "not enough packets for chirp\n");
return false;
}
@@ -136,7 +136,7 @@ static bool ath9k_check_chirping(struct ath_softc *sc, u8 
*data,
return false;
ath_dbg(common, DFS, "HT20: datalen=%d, num_fft_packets=%d\n",
datalen, num_fft_packets);
-   if (num_fft_packets < (FFT_NUM_SAMPLES)) {
+   if (num_fft_packets < FFT_NUM_SAMPLES) {
ath_dbg(common, DFS, "not enough packets for chirp\n");
return false;
}
-- 
2.7.4



Re: [PATCH] mac80211: aes-cmac: remove VLA usage

2018-03-21 Thread Gustavo A. R. Silva



On 03/21/2018 08:58 AM, Johannes Berg wrote:

On Wed, 2018-03-21 at 08:57 -0500, Gustavo A. R. Silva wrote:


SHA_DESC_ON_STACK is currently being used in multiple places. But, yeah,
I think we can define multiple macros of the same kind and adjust to the
characteristics of each the component.

How big do you think tfm can get?


I have no idea, I guess you'll have to take that with Herbert.

johannes



I see. I'll contact him then.

Thanks for the feedback.
--
Gustavo


Re: [PATCH] mac80211: aes-cmac: remove VLA usage

2018-03-21 Thread Gustavo A. R. Silva



On 03/21/2018 08:48 AM, Johannes Berg wrote:

On Wed, 2018-03-21 at 08:42 -0500, Gustavo A. R. Silva wrote:

In preparation to enabling -Wvla, remove VLAs and replace them
with dynamic memory allocation instead.

The use of stack Variable Length Arrays needs to be avoided, as they
can be a vector for stack exhaustion, which can be both a runtime bug
or a security flaw. Also, in general, as code evolves it is easy to
lose track of how big a VLA can get. Thus, we can end up having runtime
failures that are hard to debug.

Also, fixed as part of the directive to remove all VLAs from
the kernel: https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
  net/mac80211/aes_cmac.c | 36 
  1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/net/mac80211/aes_cmac.c b/net/mac80211/aes_cmac.c
index 2fb6558..c9444bf 100644
--- a/net/mac80211/aes_cmac.c
+++ b/net/mac80211/aes_cmac.c
@@ -27,30 +27,42 @@ static const u8 zero[CMAC_TLEN_256];
  void ieee80211_aes_cmac(struct crypto_shash *tfm, const u8 *aad,
const u8 *data, size_t data_len, u8 *mic)
  {
-   SHASH_DESC_ON_STACK(desc, tfm);
+   struct shash_desc *shash;
u8 out[AES_BLOCK_SIZE];
  
-	desc->tfm = tfm;

+   shash = kmalloc(sizeof(*shash) + crypto_shash_descsize(tfm),
+   GFP_KERNEL);
+   if (!shash)
+   return;


Honestly, this seems like a really bad idea - you're now hitting
kmalloc for every TX/RX frame here.

SHA_DESC_ON_STACK() should just be fixed to not need a VLA, but take
some sort of maximum, I guess?



SHA_DESC_ON_STACK is currently being used in multiple places. But, yeah, 
I think we can define multiple macros of the same kind and adjust to the 
characteristics of each the component.


How big do you think tfm can get?

Thanks
--
Gustavo


[PATCH] mac80211: aes-cmac: remove VLA usage

2018-03-21 Thread Gustavo A. R. Silva
In preparation to enabling -Wvla, remove VLAs and replace them
with dynamic memory allocation instead.

The use of stack Variable Length Arrays needs to be avoided, as they
can be a vector for stack exhaustion, which can be both a runtime bug
or a security flaw. Also, in general, as code evolves it is easy to
lose track of how big a VLA can get. Thus, we can end up having runtime
failures that are hard to debug.

Also, fixed as part of the directive to remove all VLAs from
the kernel: https://lkml.org/lkml/2018/3/7/621

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 net/mac80211/aes_cmac.c | 36 
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/net/mac80211/aes_cmac.c b/net/mac80211/aes_cmac.c
index 2fb6558..c9444bf 100644
--- a/net/mac80211/aes_cmac.c
+++ b/net/mac80211/aes_cmac.c
@@ -27,30 +27,42 @@ static const u8 zero[CMAC_TLEN_256];
 void ieee80211_aes_cmac(struct crypto_shash *tfm, const u8 *aad,
const u8 *data, size_t data_len, u8 *mic)
 {
-   SHASH_DESC_ON_STACK(desc, tfm);
+   struct shash_desc *shash;
u8 out[AES_BLOCK_SIZE];
 
-   desc->tfm = tfm;
+   shash = kmalloc(sizeof(*shash) + crypto_shash_descsize(tfm),
+   GFP_KERNEL);
+   if (!shash)
+   return;
 
-   crypto_shash_init(desc);
-   crypto_shash_update(desc, aad, AAD_LEN);
-   crypto_shash_update(desc, data, data_len - CMAC_TLEN);
-   crypto_shash_finup(desc, zero, CMAC_TLEN, out);
+   shash->tfm = tfm;
+
+   crypto_shash_init(shash);
+   crypto_shash_update(shash, aad, AAD_LEN);
+   crypto_shash_update(shash, data, data_len - CMAC_TLEN);
+   crypto_shash_finup(shash, zero, CMAC_TLEN, out);
 
memcpy(mic, out, CMAC_TLEN);
+   kfree(shash);
 }
 
 void ieee80211_aes_cmac_256(struct crypto_shash *tfm, const u8 *aad,
const u8 *data, size_t data_len, u8 *mic)
 {
-   SHASH_DESC_ON_STACK(desc, tfm);
+   struct shash_desc *shash;
+
+   shash = kmalloc(sizeof(*shash) + crypto_shash_descsize(tfm),
+   GFP_KERNEL);
+   if (!shash)
+   return;
 
-   desc->tfm = tfm;
+   shash->tfm = tfm;
 
-   crypto_shash_init(desc);
-   crypto_shash_update(desc, aad, AAD_LEN);
-   crypto_shash_update(desc, data, data_len - CMAC_TLEN_256);
-   crypto_shash_finup(desc, zero, CMAC_TLEN_256, mic);
+   crypto_shash_init(shash);
+   crypto_shash_update(shash, aad, AAD_LEN);
+   crypto_shash_update(shash, data, data_len - CMAC_TLEN_256);
+   crypto_shash_finup(shash, zero, CMAC_TLEN_256, mic);
+   kfree(shash);
 }
 
 struct crypto_shash *ieee80211_aes_cmac_key_setup(const u8 key[],
-- 
2.7.4



Re: [PATCH] drivers: net: wireless: ath: ath9: dfs: remove VLA usage

2018-03-10 Thread Gustavo A. R. Silva



On 03/10/2018 05:12 PM, Kees Cook wrote:

On Sat, Mar 10, 2018 at 3:06 PM, Arend van Spriel
 wrote:

On 3/9/2018 1:30 PM, Andreas Christoforou wrote:


The kernel would like to have all stack VLA usage removed.



I think there was a remark made earlier to give more explanation here. It
should explain why we want "VLA on stack" removed.


Signed-off-by: Andreas Christoforou 
---
   drivers/net/wireless/ath/ath9k/dfs.c | 3 +--
   1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/dfs.c
b/drivers/net/wireless/ath/ath9k/dfs.c
index 6fee9a4..cfb0f84 100644
--- a/drivers/net/wireless/ath/ath9k/dfs.c
+++ b/drivers/net/wireless/ath/ath9k/dfs.c
@@ -41,7 +41,6 @@ static const int BIN_DELTA_MAX= 10;

   /* we need at least 3 deltas / 4 samples for a reliable chirp detection
*/
   #define NUM_DIFFS 3
-static const int FFT_NUM_SAMPLES   = (NUM_DIFFS + 1);



What about this instead?

#define FFT_NUM_SAMPLES (NUM_DIFFS + 1)


   /* Threshold for difference of delta peaks */
   static const int MAX_DIFF = 2;
@@ -101,7 +100,7 @@ static bool ath9k_check_chirping(struct ath_softc *sc,
u8 *data,
  int datalen, bool is_ctl, bool is_ext)
   {
 int i;
-   int max_bin[FFT_NUM_SAMPLES];
+   int max_bin[NUM_DIFFS + 1];



Just wondering. Is this actually a VLA. FFT_NUM_SAMPLES was static const so
not really going to show a lot of variation. This array will always have the
same size on the stack.


The problem is that it's not a "constant expression", so the compiler
frontend still yells about it under -Wvla. I would characterize this
mainly as a fix for "accidental VLA" or "misdetected VLA" or something
like that. AIUI, there really isn't a functional change here.

-Kees



--
Gustavo


[PATCH] ssb: return boolean instead of integer in ssb_dma_translation_special_bit

2018-01-18 Thread Gustavo A. R. Silva
Return statements in functions returning bool should use
true/false instead of 1/0.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/ssb/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index 65420a9..fdb89b6 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -1116,7 +1116,7 @@ static bool ssb_dma_translation_special_bit(struct 
ssb_device *dev)
chip_id == 43231 || chip_id == 43222);
}
 
-   return 0;
+   return false;
 }
 
 u32 ssb_dma_translation(struct ssb_device *dev)
-- 
2.7.4



[PATCH] rsi: rsi_91x_ps: remove redundant code in str_psstate

2017-11-06 Thread Gustavo A. R. Silva
"INVALID_STATE" is already being returned in the default case and this
code cannot be reached.

Addresses-Coverity-ID: 1398384
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/net/wireless/rsi/rsi_91x_ps.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_ps.c 
b/drivers/net/wireless/rsi/rsi_91x_ps.c
index 523f532..01472fa 100644
--- a/drivers/net/wireless/rsi/rsi_91x_ps.c
+++ b/drivers/net/wireless/rsi/rsi_91x_ps.c
@@ -36,7 +36,6 @@ char *str_psstate(enum ps_state state)
default:
return "INVALID_STATE";
}
-   return "INVALID_STATE";
 }
 
 static inline void rsi_modify_ps_state(struct rsi_hw *adapter,
-- 
2.7.4



[PATCH] ath9k: dfs: use swap macro in ath9k_check_chirping

2017-11-03 Thread Gustavo A. R. Silva
Make use of the swap macro and remove unnecessary variable temp.
This makes the code easier to read and maintain.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/net/wireless/ath/ath9k/dfs.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/dfs.c 
b/drivers/net/wireless/ath/ath9k/dfs.c
index 40a397f..6fee9a4 100644
--- a/drivers/net/wireless/ath/ath9k/dfs.c
+++ b/drivers/net/wireless/ath/ath9k/dfs.c
@@ -123,11 +123,9 @@ static bool ath9k_check_chirping(struct ath_softc *sc, u8 
*data,
fft = (struct ath9k_dfs_fft_40 *) (data + 2);
ath_dbg(common, DFS, "fixing datalen by 2\n");
}
-   if (IS_CHAN_HT40MINUS(ah->curchan)) {
-   int temp = is_ctl;
-   is_ctl = is_ext;
-   is_ext = temp;
-   }
+   if (IS_CHAN_HT40MINUS(ah->curchan))
+   swap(is_ctl, is_ext);
+
for (i = 0; i < FFT_NUM_SAMPLES; i++)
max_bin[i] = ath9k_get_max_index_ht40(fft + i, is_ctl,
  is_ext);
-- 
2.7.4



[PATCH] net: wireless: mark expected switch fall-throughs

2017-10-20 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
This code was tested by compilation only (GCC 7.2.0 was used).
Please, verify if the actual intention of the code is to fall through.

 net/wireless/chan.c|  2 ++
 net/wireless/nl80211.c | 10 ++
 net/wireless/scan.c|  3 ++-
 net/wireless/wext-compat.c |  2 ++
 4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index eb82427..6072613 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -741,6 +741,7 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
case NL80211_CHAN_WIDTH_20:
if (!ht_cap->ht_supported)
return false;
+   /* fall through */
case NL80211_CHAN_WIDTH_20_NOHT:
prohibited_flags |= IEEE80211_CHAN_NO_20MHZ;
width = 20;
@@ -763,6 +764,7 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
cap = vht_cap->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK;
if (cap != IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ)
return false;
+   /* fall through */
case NL80211_CHAN_WIDTH_80:
if (!vht_cap->vht_supported)
return false;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index fce2cbe..a8bbb6c 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1509,6 +1509,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
state->split_start++;
if (state->split)
break;
+   /* fall through */
case 1:
if (nla_put(msg, NL80211_ATTR_CIPHER_SUITES,
sizeof(u32) * rdev->wiphy.n_cipher_suites,
@@ -1555,6 +1556,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
state->split_start++;
if (state->split)
break;
+   /* fall through */
case 2:
if (nl80211_put_iftypes(msg, NL80211_ATTR_SUPPORTED_IFTYPES,
rdev->wiphy.interface_modes))
@@ -1562,6 +1564,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
state->split_start++;
if (state->split)
break;
+   /* fall through */
case 3:
nl_bands = nla_nest_start(msg, NL80211_ATTR_WIPHY_BANDS);
if (!nl_bands)
@@ -1587,6 +1590,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
state->chan_start++;
if (state->split)
break;
+   /* fall through */
default:
/* add frequencies */
nl_freqs = nla_nest_start(
@@ -1640,6 +1644,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
state->split_start++;
if (state->split)
break;
+   /* fall through */
case 4:
nl_cmds = nla_nest_start(msg, NL80211_ATTR_SUPPORTED_COMMANDS);
if (!nl_cmds)
@@ -1666,6 +1671,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
state->split_start++;
if (state->split)
break;
+   /* fall through */
case 5:
if (rdev->ops->remain_on_channel &&
(rdev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL) &&
@@ -1683,6 +1689,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
state->split_start++;
if (state->split)
break;
+   /* fall through */
case 6:
 #ifdef CONFIG_PM
if (nl80211_send_wowlan(msg, rdev, state->split))
@@ -1693,6 +1700,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
 #else
state->split_start++;
 #endif
+   /* fall through */
case 7:
if (nl80211_put_iftypes(msg, NL80211_ATTR_SOFTWARE_IFTYPES,
rdev->wiphy.software_iftypes))
@@ -1705,6 +1713,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
state->split_start++;
if (state->split)
break;
+   /* fall through */
case 8:
if ((rdev->wiphy.flags & WIPHY_FLAG_HAVE_AP_SME) &a

[PATCH] net: mac80211: mark expected switch fall-throughs

2017-10-17 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Notice that in some cases I replaced "fall through on else" and
"otherwise fall through" comments with just a "fall through" comment,
which is what GCC is expecting to find.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
This code was tested by compilation only (GCC 7.2.0 was used).
Please, verify that the actual intention of the code is to fall through.

 net/mac80211/cfg.c| 3 +++
 net/mac80211/ht.c | 1 +
 net/mac80211/iface.c  | 2 +-
 net/mac80211/mesh.c   | 2 ++
 net/mac80211/mesh_hwmp.c  | 1 +
 net/mac80211/mesh_plink.c | 2 +-
 net/mac80211/mlme.c   | 1 +
 net/mac80211/offchannel.c | 4 ++--
 net/mac80211/tdls.c   | 1 +
 net/mac80211/wme.c| 1 +
 10 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index a354f19..9bd8bef 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -573,10 +573,12 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct 
net_device *dev,
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
 offsetof(typeof(kseq), aes_cmac));
+   /* fall through */
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
 offsetof(typeof(kseq), aes_gmac));
+   /* fall through */
case WLAN_CIPHER_SUITE_GCMP:
case WLAN_CIPHER_SUITE_GCMP_256:
BUILD_BUG_ON(offsetof(typeof(kseq), ccmp) !=
@@ -2205,6 +2207,7 @@ static int ieee80211_scan(struct wiphy *wiphy,
 * for now fall through to allow scanning only when
 * beaconing hasn't been configured yet
 */
+   /* fall through */
case NL80211_IFTYPE_AP:
/*
 * If the scan has been forced (and the driver supports
diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c
index 41f5e48..e55dabf 100644
--- a/net/mac80211/ht.c
+++ b/net/mac80211/ht.c
@@ -491,6 +491,7 @@ int ieee80211_send_smps_action(struct ieee80211_sub_if_data 
*sdata,
case IEEE80211_SMPS_AUTOMATIC:
case IEEE80211_SMPS_NUM_MODES:
WARN_ON(1);
+   /* fall through */
case IEEE80211_SMPS_OFF:
action_frame->u.action.u.ht_smps.smps_control =
WLAN_HT_SMPS_CONTROL_DISABLED;
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 13b16f9..435e735 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1633,7 +1633,7 @@ static void ieee80211_assign_perm_addr(struct 
ieee80211_local *local,
goto out_unlock;
}
}
-   /* otherwise fall through */
+   /* fall through */
default:
/* assign a new address if possible -- try n_addresses first */
for (i = 0; i < local->hw.wiphy->n_addresses; i++) {
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 7a76c4a..d29a545 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -988,8 +988,10 @@ ieee80211_mesh_process_chnswitch(struct 
ieee80211_sub_if_data *sdata,
switch (sdata->vif.bss_conf.chandef.width) {
case NL80211_CHAN_WIDTH_20_NOHT:
sta_flags |= IEEE80211_STA_DISABLE_HT;
+   /* fall through */
case NL80211_CHAN_WIDTH_20:
sta_flags |= IEEE80211_STA_DISABLE_40MHZ;
+   /* fall through */
case NL80211_CHAN_WIDTH_40:
sta_flags |= IEEE80211_STA_DISABLE_VHT;
break;
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 146ec6c..0e75abf 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -1247,6 +1247,7 @@ void mesh_path_tx_root_frame(struct ieee80211_sub_if_data 
*sdata)
break;
case IEEE80211_PROACTIVE_PREQ_WITH_PREP:
flags |= IEEE80211_PREQ_PROACTIVE_PREP_FLAG;
+   /* fall through */
case IEEE80211_PROACTIVE_PREQ_NO_PREP:
interval = ifmsh->mshcfg.dot11MeshHWMPactivePathToRootTimeout;
target_flags |= IEEE80211_PREQ_TO_FLAG |
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index e2d00cc..0f6c9ca 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -672,7 +672,7 @@ void mesh_plink_timer(struct timer_list *t)
break;
}
reason = WLAN_REASON_MESH_MAX_RETRIES;
-   /* fall through on else */
+   /* fall through */
case NL80211_PLINK_CNF_RCVD:
/* confirm timer */
if (!reason)
diff --git a/n

Re: [PATCH] rtl8xxxu: mark expected switch fall-throughs

2017-10-11 Thread Gustavo A. R. Silva

Hi Jes,

Quoting Jes Sorensen <jes.soren...@gmail.com>:


On 10/11/2017 04:41 AM, Kalle Valo wrote:

Jes Sorensen <jes.soren...@gmail.com> writes:


On 10/10/2017 03:30 PM, Gustavo A. R. Silva wrote:

In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.


While this isn't harmful, to me this looks like pointless patch churn
for zero gain and it's just ugly.


In general I find it useful to mark fall through cases. And it's just a
comment with two words, so they cannot hurt your eyes that much.


I don't see them being harmful in the code, but I don't see them of  
much use either. If it happened as part of natural code development,  
fine. My objection is to people running around doing this  
systematically causing patch churn for little to zero gain.


Jes



I understand that you think this is of zero gain for you, but as  
Florian Fainelli pointed out:


"That is the canonical way to tell static analyzers and compilers that
fall throughs are wanted and not accidental mistakes in the code. For
people that deal with these kinds of errors, it's quite helpful, unless
you suggest disabling that particular GCC warning specific for that
file/directory?"

this is very helpful for people working on fixing issues reported by  
static analyzers. It saves a huge amount of time when dealing with  
False Positives. Also, there are cases when an apparently intentional  
fall-through turns out to be an actual missing break or continue.


So there is an ongoing effort to detect such cases and avoid them to  
show up in the future by at least warning people about a potential  
issue in their code. And this is helpful for everybody.


Thanks
--
Gustavo A. R. Silva







[PATCH] rtl8xxxu: mark expected switch fall-throughs

2017-10-10 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Cc: Jes Sorensen <jes.soren...@gmail.com>
Cc: Kalle Valo <kv...@codeaurora.org>
Cc: linux-wireless@vger.kernel.org
Cc: net...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c 
b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index 7806a4d..e66be05 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -1153,6 +1153,7 @@ void rtl8xxxu_gen1_config_channel(struct ieee80211_hw *hw)
switch (hw->conf.chandef.width) {
case NL80211_CHAN_WIDTH_20_NOHT:
ht = false;
+   /* fall through */
case NL80211_CHAN_WIDTH_20:
opmode |= BW_OPMODE_20MHZ;
rtl8xxxu_write8(priv, REG_BW_OPMODE, opmode);
@@ -1280,6 +1281,7 @@ void rtl8xxxu_gen2_config_channel(struct ieee80211_hw *hw)
switch (hw->conf.chandef.width) {
case NL80211_CHAN_WIDTH_20_NOHT:
ht = false;
+   /* fall through */
case NL80211_CHAN_WIDTH_20:
rf_mode_bw |= WMAC_TRXPTCL_CTL_BW_20;
subchannel = 0;
@@ -1748,9 +1750,11 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv 
*priv)
case 3:
priv->ep_tx_low_queue = 1;
priv->ep_tx_count++;
+   /* fall through */
case 2:
priv->ep_tx_normal_queue = 1;
priv->ep_tx_count++;
+   /* fall through */
case 1:
priv->ep_tx_high_queue = 1;
priv->ep_tx_count++;
@@ -5691,6 +5695,7 @@ static int rtl8xxxu_set_key(struct ieee80211_hw *hw, enum 
set_key_cmd cmd,
break;
case WLAN_CIPHER_SUITE_TKIP:
key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
+   /* fall through */
default:
return -EOPNOTSUPP;
}
-- 
2.7.4



Re: [PATCH] rtlwifi: btcoex: 23b 1ant: fix duplicated code for different branches

2017-09-07 Thread Gustavo A. R. Silva

Hi Larry,

On 08/30/2017 11:48 PM, Larry Finger wrote:

On 08/30/2017 08:42 AM, Gustavo A. R. Silva wrote:

Refactor code in order to avoid identical code for different branches.

This issue was detected with the help of Coccinelle.

Addresses-Coverity-ID: 1226788
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
This issue was reported by Coverity and it was tested by compilation
only.
I'm suspicious this may be a copy/paste error. Please, verify.

  .../net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c   | 10
++
  1 file changed, 2 insertions(+), 8 deletions(-)


This change is not correct. When bt_link_info->sco_exist is true, the
call should be

halbtc8723b1ant_limited_rx(btcoexist,
   NORMAL_EXEC, true,
   false, 0x5);

NACK

I will push the correct patch.



Great. Good to know.

Thanks
--
Gustavo A. R. Silva


[PATCH] rtlwifi: rtl8723be: fix duplicated code for different branches

2017-08-30 Thread Gustavo A. R. Silva
Refactor code in order to avoid identical code for different branches.

Addresses-Coverity-ID: 1248728
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
This issue was reported by Coverity and it was tested by compilation only.
Please, verify if this is not a copy/paste error.
Also, notice this code has been there since 2014.

 drivers/net/wireless/realtek/rtlwifi/rtl8723be/dm.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/dm.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/dm.c
index 131c0d1..15c117e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/dm.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/dm.c
@@ -883,12 +883,8 @@ static void 
rtl8723be_dm_txpower_tracking_callback_thermalmeter(
if ((rtldm->power_index_offset[RF90_PATH_A] != 0) &&
(rtldm->txpower_track_control)) {
rtldm->done_txpower = true;
-   if (thermalvalue > rtlefuse->eeprom_thermalmeter)
-   rtl8723be_dm_tx_power_track_set_power(hw, BBSWING, 0,
-index_for_channel);
-   else
-   rtl8723be_dm_tx_power_track_set_power(hw, BBSWING, 0,
-index_for_channel);
+   rtl8723be_dm_tx_power_track_set_power(hw, BBSWING, 0,
+ index_for_channel);
 
rtldm->swing_idx_cck_base = rtldm->swing_idx_cck;
rtldm->swing_idx_ofdm_base[RF90_PATH_A] =
-- 
2.5.0



Re: [PATCH] rtlwifi: btcoex: 23b 1ant: fix duplicated code for different branches

2017-08-30 Thread Gustavo A. R. Silva

Hi Larry,

On 08/30/2017 11:37 AM, Larry Finger wrote:

On 08/30/2017 08:42 AM, Gustavo A. R. Silva wrote:

Refactor code in order to avoid identical code for different branches.

This issue was detected with the help of Coccinelle.

Addresses-Coverity-ID: 1226788
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
This issue was reported by Coverity and it was tested by compilation
only.
I'm suspicious this may be a copy/paste error. Please, verify.


I have referred this change to the engineers at Realtek. For the moment,
please hold this patch.

Thanks for reporting the condition.



Glad to help. :)

--
Gustavo A. R. Silva


[PATCH] rtlwifi: refactor code in halbtcoutsrc module

2017-08-30 Thread Gustavo A. R. Silva
Function halbtc_get_wifi_rssi always returns rtlpriv->dm.undec_sm_pwdb.
So this function can be removed and the value of
rtlpriv->dm.undec_sm_pwdb assigned to *s32_tmp directly.

This issue was first reported by Coverity as "identical code for different
branches" in function halbtc_get_wifi_rssi.

Addresses-Coverity-ID: 1226793
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
This code was reported by Coverity and it was tested by compilation only.
Chances are this may be a copy/paste error in function
halbtc_get_wifi_rssi. Please, verify.
Also, notice this code has been there since 2014.

 .../net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c   | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
index c1eacd8..2a47b97 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c
@@ -373,17 +373,6 @@ u32 halbtc_get_wifi_link_status(struct btc_coexist 
*btcoexist)
return ret_val;
 }
 
-static s32 halbtc_get_wifi_rssi(struct rtl_priv *rtlpriv)
-{
-   int undec_sm_pwdb = 0;
-
-   if (rtlpriv->mac80211.link_state >= MAC80211_LINKED)
-   undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
-   else /* associated entry pwdb */
-   undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb;
-   return undec_sm_pwdb;
-}
-
 static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf)
 {
struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist;
@@ -479,7 +468,7 @@ static bool halbtc_get(void *void_btcoexist, u8 get_type, 
void *out_buf)
*bool_tmp = false;
break;
case BTC_GET_S4_WIFI_RSSI:
-   *s32_tmp = halbtc_get_wifi_rssi(rtlpriv);
+   *s32_tmp = rtlpriv->dm.undec_sm_pwdb;
break;
case BTC_GET_S4_HS_RSSI:
*s32_tmp = 0;
-- 
2.5.0



[PATCH] rtlwifi: btcoex: 23b 1ant: fix duplicated code for different branches

2017-08-30 Thread Gustavo A. R. Silva
Refactor code in order to avoid identical code for different branches.

This issue was detected with the help of Coccinelle.

Addresses-Coverity-ID: 1226788
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
This issue was reported by Coverity and it was tested by compilation only.
I'm suspicious this may be a copy/paste error. Please, verify.

 .../net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c   | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c
index c044252..960ce80f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c
@@ -2260,14 +2260,8 @@ static void halbtc8723b1ant_run_coexist_mechanism(struct 
btc_coexist *btcoexist)
 
if (iot_peer != BTC_IOT_PEER_CISCO &&
iot_peer != BTC_IOT_PEER_BROADCOM) {
-   if (bt_link_info->sco_exist)
-   halbtc8723b1ant_limited_rx(btcoexist,
-  NORMAL_EXEC, false,
-  false, 0x5);
-   else
-   halbtc8723b1ant_limited_rx(btcoexist,
-  NORMAL_EXEC, false,
-  false, 0x5);
+   halbtc8723b1ant_limited_rx(btcoexist, NORMAL_EXEC,
+  false, false, 0x5);
} else {
if (bt_link_info->sco_exist) {
halbtc8723b1ant_limited_rx(btcoexist,
-- 
2.5.0



[PATCH] rtlwifi: btcoex: 23b 1ant: fix duplicated code for different branches

2017-08-17 Thread Gustavo A. R. Silva
Refactor code in order to avoid identical code for different branches.

This issue was detected with the help of Coccinelle.

Addresses-Coverity-ID: 1415177
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
This issue was reported by Coverity and it was tested by compilation only.

 .../net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c   | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c 
b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c
index 03998d2..c044252 100644
--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8723b1ant.c
@@ -600,14 +600,8 @@ static void halbtc8723b1ant_coex_table_with_type(struct 
btc_coexist *btcoexist,
   0xff, 0x3);
break;
case 5:
-   if ((coex_sta->cck_ever_lock) && (coex_sta->scan_ap_num <= 5))
-   halbtc8723b1ant_coex_table(btcoexist, force_exec,
-  0x5a5a5a5a, 0x5aaa5a5a,
-  0xff, 0x3);
-   else
-   halbtc8723b1ant_coex_table(btcoexist, force_exec,
-  0x5a5a5a5a, 0x5aaa5a5a,
-  0xff, 0x3);
+   halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a,
+  0x5aaa5a5a, 0xff, 0x3);
break;
case 6:
halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x,
-- 
2.5.0



[PATCH] rtlwifi: remove useless code

2017-07-18 Thread Gustavo A. R. Silva
Remove useless local variables last_read_point and last_txw_point and
the code related.

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
index 55f238a..c58393e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/trx.c
@@ -478,7 +478,6 @@ u16 rtl92ee_rx_desc_buff_remained_cnt(struct ieee80211_hw 
*hw, u8 queue_index)
struct rtl_priv *rtlpriv = rtl_priv(hw);
u16 read_point = 0, write_point = 0, remind_cnt = 0;
u32 tmp_4byte = 0;
-   static u16 last_read_point;
static bool start_rx;
 
tmp_4byte = rtl_read_dword(rtlpriv, REG_RXQ_TXBD_IDX);
@@ -506,7 +505,6 @@ u16 rtl92ee_rx_desc_buff_remained_cnt(struct ieee80211_hw 
*hw, u8 queue_index)
 
rtlpci->rx_ring[queue_index].next_rx_rp = write_point;
 
-   last_read_point = read_point;
return remind_cnt;
 }
 
@@ -917,7 +915,6 @@ void rtl92ee_set_desc(struct ieee80211_hw *hw, u8 *pdesc, 
bool istx,
struct rtl_priv *rtlpriv = rtl_priv(hw);
u16 cur_tx_rp = 0;
u16 cur_tx_wp = 0;
-   static u16 last_txw_point;
static bool over_run;
u32 tmp = 0;
u8 q_idx = *val;
@@ -951,9 +948,6 @@ void rtl92ee_set_desc(struct ieee80211_hw *hw, u8 *pdesc, 
bool istx,
rtl_write_word(rtlpriv,
   get_desc_addr_fr_q_idx(q_idx),
   ring->cur_tx_wp);
-
-   if (q_idx == 1)
-   last_txw_point = cur_tx_wp;
}
 
if (ring->avl_desc < (max_tx_desc - 15)) {
-- 
2.5.0



[PATCH] wireless: airo: remove unnecessary static in writerids()

2017-07-18 Thread Gustavo A. R. Silva
Remove unnecessary static on local function pointer _writer_.
Such pointer is initialized before being used, on every
execution path throughout the function. The static has no
benefit and, removing it reduces the object file size.

This issue was detected using Coccinelle and the following semantic patch:

@bad exists@
position p;
identifier x;
type T;
@@

static T x@p;
...
x = <+...x...+>

@@
identifier x;
expression e;
type T;
position p != bad.p;
@@

-static
 T x@p;
 ... when != x
 when strict
?x = e;

In the following log you can see a significant difference in the object
file size. This log is the output of the size command, before and after
the code change:

before:
   textdata bss dec hex filename
 113797   191521216  134165   20c15 drivers/net/wireless/cisco/airo.o

after:
   textdata bss dec hex filename
 113881   190961152  134129   20bf1 drivers/net/wireless/cisco/airo.o

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/net/wireless/cisco/airo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/cisco/airo.c 
b/drivers/net/wireless/cisco/airo.c
index 84143a0..1066d84 100644
--- a/drivers/net/wireless/cisco/airo.c
+++ b/drivers/net/wireless/cisco/airo.c
@@ -7837,7 +7837,7 @@ static int writerids(struct net_device *dev, 
aironet_ioctl *comp) {
struct airo_info *ai = dev->ml_priv;
int  ridcode;
 int  enabled;
-   static int (* writer)(struct airo_info *, u16 rid, const void *, int, 
int);
+   int (*writer)(struct airo_info *, u16 rid, const void *, int, int);
unsigned char *iobuf;
 
/* Only super-user can write RIDs */
-- 
2.5.0



Re: ti: wl18xx: add checks on wl18xx_top_reg_write() return value

2017-06-28 Thread Gustavo A. R. Silva


Quoting Kalle Valo <kv...@codeaurora.org>:


"Gustavo A. R. Silva" <garsi...@embeddedor.com> wrote:


Check return value from call to wl18xx_top_reg_write(),
so in case of error jump to goto label out and return.

Also, remove unnecessary value check before goto label out.

Addresses-Coverity-ID: 1226938
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>


The prefix should be "wl18xx:", I'll fix that.



Thanks, Kalle.
--
Gustavo A. R. Silva







[PATCH] ath9k: remove useless variable assignment in ath_mci_intr()

2017-06-26 Thread Gustavo A. R. Silva
Value assigned to variable offset at line 551 is overwritten at line 562,
before it can be used. This makes such variable assignment useless.

Addresses-Coverity-ID: 1226941
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/net/wireless/ath/ath9k/mci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/mci.c 
b/drivers/net/wireless/ath/ath9k/mci.c
index 66596b9..cf23fd8 100644
--- a/drivers/net/wireless/ath/ath9k/mci.c
+++ b/drivers/net/wireless/ath/ath9k/mci.c
@@ -548,7 +548,7 @@ void ath_mci_intr(struct ath_softc *sc)
 
if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO) {
mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO;
-   offset = ar9003_mci_state(ah, MCI_STATE_LAST_SCHD_MSG_OFFSET);
+   ar9003_mci_state(ah, MCI_STATE_LAST_SCHD_MSG_OFFSET);
}
 
if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_GPM) {
-- 
2.5.0



[PATCH] ti: wl18xx: add checks on wl18xx_top_reg_write() return value

2017-06-26 Thread Gustavo A. R. Silva
Check return value from call to wl18xx_top_reg_write(),
so in case of error jump to goto label out and return.

Also, remove unnecessary value check before goto label out.

Addresses-Coverity-ID: 1226938
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/net/wireless/ti/wl18xx/main.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ti/wl18xx/main.c 
b/drivers/net/wireless/ti/wl18xx/main.c
index d1aa3ee..0cf3b40 100644
--- a/drivers/net/wireless/ti/wl18xx/main.c
+++ b/drivers/net/wireless/ti/wl18xx/main.c
@@ -793,9 +793,13 @@ static int wl18xx_set_clk(struct wl1271 *wl)
ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_2,
(wl18xx_clk_table[clk_freq].p >> 16) &
PLLSH_WCS_PLL_P_FACTOR_CFG_2_MASK);
+   if (ret < 0)
+   goto out;
} else {
ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_SWALLOW_EN,
   PLLSH_WCS_PLL_SWALLOW_EN_VAL2);
+   if (ret < 0)
+   goto out;
}
 
/* choose WCS PLL */
@@ -819,8 +823,6 @@ static int wl18xx_set_clk(struct wl1271 *wl)
/* reset the swallowing logic */
ret = wl18xx_top_reg_write(wl, PLLSH_COEX_PLL_SWALLOW_EN,
   PLLSH_COEX_PLL_SWALLOW_EN_VAL2);
-   if (ret < 0)
-   goto out;
 
 out:
return ret;
-- 
2.5.0



[PATCH] rtlwifi: rtl8821ae: remove unused variable

2017-06-13 Thread Gustavo A. R. Silva
Remove unused variable rtlhal.

Addresses-Coverity-ID: 1248810
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
index 2bc6bac..d158e34 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
@@ -1360,7 +1360,6 @@ static bool _rtl8821ae_reset_pcie_interface_dma(struct 
ieee80211_hw *hw,
 static void _rtl8821ae_get_wakeup_reason(struct ieee80211_hw *hw)
 {
struct rtl_priv *rtlpriv = rtl_priv(hw);
-   struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv);
u8 fw_reason = 0;
struct timeval ts;
@@ -1372,8 +1371,6 @@ static void _rtl8821ae_get_wakeup_reason(struct 
ieee80211_hw *hw)
 
ppsc->wakeup_reason = 0;
 
-   rtlhal->last_suspend_sec = ts.tv_sec;
-
switch (fw_reason) {
case FW_WOW_V2_PTK_UPDATE_EVENT:
ppsc->wakeup_reason = WOL_REASON_PTK_UPDATE;
-- 
2.5.0



[PATCH] nfc: nci: remove unnecessary null check

2017-06-13 Thread Gustavo A. R. Silva
Remove unnecessary NULL check for pointer conn_info.
conn_info is set in list_for_each_entry() using container_of(),
which is never NULL.

Addresses-Coverity-ID: 1362349
Cc: Guenter Roeck <li...@roeck-us.net>
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 net/nfc/nci/core.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 61fff42..c15cb88 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -73,11 +73,10 @@ int nci_get_conn_info_by_dest_type_params(struct nci_dev 
*ndev, u8 dest_type,
if (conn_info->dest_type == dest_type) {
if (!params)
return conn_info->conn_id;
-   if (conn_info) {
-   if (params->id == conn_info->dest_params->id &&
-   params->protocol == 
conn_info->dest_params->protocol)
-   return conn_info->conn_id;
-   }
+
+   if (params->id == conn_info->dest_params->id &&
+   params->protocol == 
conn_info->dest_params->protocol)
+   return conn_info->conn_id;
}
}
 
-- 
2.5.0



[PATCH] nfc: nci: fix potential NULL pointer dereference

2017-06-12 Thread Gustavo A. R. Silva
NULL check at line 76: if (conn_info) {, implies that pointer conn_info
might be NULL, but this pointer is being previously dereferenced,
which might cause a NULL pointer dereference.

Add NULL check before dereferencing pointer conn_info in order to
avoid a potential NULL pointer dereference.

Addresses-Coverity-ID: 1362349
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 net/nfc/nci/core.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 61fff42..d2198ce 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -70,14 +70,13 @@ int nci_get_conn_info_by_dest_type_params(struct nci_dev 
*ndev, u8 dest_type,
struct nci_conn_info *conn_info;
 
list_for_each_entry(conn_info, >conn_info_list, list) {
-   if (conn_info->dest_type == dest_type) {
+   if (conn_info && conn_info->dest_type == dest_type) {
if (!params)
return conn_info->conn_id;
-   if (conn_info) {
-   if (params->id == conn_info->dest_params->id &&
-   params->protocol == 
conn_info->dest_params->protocol)
-   return conn_info->conn_id;
-   }
+
+   if (params->id == conn_info->dest_params->id &&
+   params->protocol == 
conn_info->dest_params->protocol)
+   return conn_info->conn_id;
}
}
 
-- 
2.5.0



Re: nfc: nci: fix potential NULL pointer dereference

2017-06-12 Thread Gustavo A. R. Silva

Hi Guenter,

Please, see my comments below

Quoting Guenter Roeck <li...@roeck-us.net>:


On Mon, Jun 12, 2017 at 05:02:23PM -0500, Gustavo A. R. Silva wrote:

NULL check at line 76: if (conn_info) {, implies that pointer conn_info
might be NULL, but this pointer is being previously dereferenced,
which might cause a NULL pointer dereference.

Add NULL check before dereferencing pointer conn_info in order to
avoid a potential NULL pointer dereference.

Addresses-Coverity-ID: 1362349
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 net/nfc/nci/core.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 61fff42..d2198ce 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -70,14 +70,13 @@ int  
nci_get_conn_info_by_dest_type_params(struct nci_dev *ndev, u8  
dest_type,

struct nci_conn_info *conn_info;

list_for_each_entry(conn_info, >conn_info_list, list) {


conn_info is set in list_for_each_entry() using container_of(),
which is never NULL. Plus, it is dereferenced there as well.
The check is unnecessary.



Thanks for clarifying.


Guenter


-   if (conn_info->dest_type == dest_type) {
+   if (conn_info && conn_info->dest_type == dest_type) {
if (!params)
return conn_info->conn_id;
-   if (conn_info) {


So, this NULL check could be removed as it seems it is not useful at all ?


-   if (params->id == conn_info->dest_params->id &&
-   params->protocol == 
conn_info->dest_params->protocol)
-   return conn_info->conn_id;
-   }
+
+   if (params->id == conn_info->dest_params->id &&
+   params->protocol == 
conn_info->dest_params->protocol)
+           return conn_info->conn_id;
}
}



Thank you
--
Gustavo A. R. Silva








[PATCH] wireless: wlcore: spi: remove unnecessary variable

2017-06-08 Thread Gustavo A. R. Silva
Remove unnecessary variable and refactor the code.

Addresses-Coverity-ID: 1365000
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/net/wireless/ti/wlcore/spi.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ti/wlcore/spi.c 
b/drivers/net/wireless/ti/wlcore/spi.c
index fa3547e..d2d899a 100644
--- a/drivers/net/wireless/ti/wlcore/spi.c
+++ b/drivers/net/wireless/ti/wlcore/spi.c
@@ -366,17 +366,14 @@ static int __wl12xx_spi_raw_write(struct device *child, 
int addr,
 static int __must_check wl12xx_spi_raw_write(struct device *child, int addr,
 void *buf, size_t len, bool fixed)
 {
-   int ret;
-
/* The ELP wakeup write may fail the first time due to internal
 * hardware latency. It is safer to send the wakeup command twice to
 * avoid unexpected failures.
 */
if (addr == HW_ACCESS_ELP_CTRL_REG)
-   ret = __wl12xx_spi_raw_write(child, addr, buf, len, fixed);
-   ret = __wl12xx_spi_raw_write(child, addr, buf, len, fixed);
+   __wl12xx_spi_raw_write(child, addr, buf, len, fixed);
 
-   return ret;
+   return __wl12xx_spi_raw_write(child, addr, buf, len, fixed);
 }
 
 /**
-- 
2.5.0



[PATCH] NFC: add NULL checks to avoid potential NULL pointer dereference

2017-05-30 Thread Gustavo A. R. Silva
NULL checks at line 457: if (!link0 || !link1) {, implies that both
pointers link0 and link1 might be NULL.
Function nfcsim_link_free() dereference pointers link0 and link1.
Add NULL checks before calling nfcsim_link_free() to avoid a
potential NULL pointer dereference.

Addresses-Coverity-ID: 1364857
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/nfc/nfcsim.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nfc/nfcsim.c b/drivers/nfc/nfcsim.c
index a466e79..6e90b54 100644
--- a/drivers/nfc/nfcsim.c
+++ b/drivers/nfc/nfcsim.c
@@ -482,8 +482,10 @@ static int __init nfcsim_init(void)
 exit_err:
pr_err("Failed to initialize nfcsim driver (%d)\n", rc);
 
-   nfcsim_link_free(link0);
-   nfcsim_link_free(link1);
+   if (link0)
+   nfcsim_link_free(link0);
+   if (link1)
+   nfcsim_link_free(link1);
 
return rc;
 }
-- 
2.5.0



[net-wireless-orinoco] question about potential null pointer dereference

2017-05-30 Thread Gustavo A. R. Silva


Hello everybody,

While looking into Coverity ID 1357460 I ran into the following piece  
of code at drivers/net/wireless/intersil/orinoco/mic.c:48


48int orinoco_mic(struct crypto_shash *tfm_michael, u8 *key,
49u8 *da, u8 *sa, u8 priority,
50u8 *data, size_t data_len, u8 *mic)
51{
52SHASH_DESC_ON_STACK(desc, tfm_michael);
53u8 hdr[ETH_HLEN + 2]; /* size of header + padding */
54int err;
55
56if (tfm_michael == NULL) {
57printk(KERN_WARNING "orinoco_mic: tfm_michael == NULL\n");
58return -1;
59}
60
61/* Copy header into buffer. We need the padding on the end zeroed */
62memcpy([0], da, ETH_ALEN);
63memcpy([ETH_ALEN], sa, ETH_ALEN);
64hdr[ETH_ALEN * 2] = priority;
65hdr[ETH_ALEN * 2 + 1] = 0;
66hdr[ETH_ALEN * 2 + 2] = 0;
67hdr[ETH_ALEN * 2 + 3] = 0;
68
69desc->tfm = tfm_michael;
70desc->flags = 0;
71
72err = crypto_shash_setkey(tfm_michael, key, MIC_KEYLEN);
73if (err)
74return err;
75
76err = crypto_shash_init(desc);
77if (err)
78return err;
79
80err = crypto_shash_update(desc, hdr, sizeof(hdr));
81if (err)
82return err;
83
84err = crypto_shash_update(desc, data, data_len);
85if (err)
86return err;
87
88err = crypto_shash_final(desc, mic);
89shash_desc_zero(desc);
90
91return err;
92}

The issue here is that line 56 implies that pointer tfm_michael might  
be NULL. If this is the case, there is a potential NULL pointer  
dereference at line 52 once pointer tfm_michael is indirectly  
dereferenced inside macro SHASH_DESC_ON_STACK().


My question is if there is any chance that pointer tfm_michael might  
be NULL when calling macro SHASH_DESC_ON_STACK() ?


I'm trying to figure out if this is a false positive or something that  
needs to be fixed somehow.


I'd really appreciate any comment on this.

Thank you!
--
Gustavo A. R. Silva






[net-realtek-btcoexist] question about identical code for different branches

2017-05-17 Thread Gustavo A. R. Silva


Hello everybody,

While looking into Coverity ID 1362263 I ran into the following piece  
of code at  
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtcoutsrc.c:1000:


1000void exhalbtc_set_ant_num(struct rtl_priv *rtlpriv, u8 type, u8 ant_num)
1001{
1002if (BT_COEX_ANT_TYPE_PG == type) {
1003gl_bt_coexist.board_info.pg_ant_num = ant_num;
1004gl_bt_coexist.board_info.btdm_ant_num = ant_num;
1005/* The antenna position:
1006 * Main (default) or Aux for pgAntNum=2 && btdmAntNum =1.
1007 * The antenna position should be determined by
1008 * auto-detect mechanism.
1009 * The following is assumed to main,
1010 * and those must be modified
1011 * if y auto-detect mechanism is ready
1012 */
1013if ((gl_bt_coexist.board_info.pg_ant_num == 2) &&
1014(gl_bt_coexist.board_info.btdm_ant_num == 1))
1015gl_bt_coexist.board_info.btdm_ant_pos =
1016
BTC_ANTENNA_AT_MAIN_PORT;

1017else
1018gl_bt_coexist.board_info.btdm_ant_pos =
1019
BTC_ANTENNA_AT_MAIN_PORT;

1020} else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
1021gl_bt_coexist.board_info.btdm_ant_num = ant_num;
1022gl_bt_coexist.board_info.btdm_ant_pos =
1023
BTC_ANTENNA_AT_MAIN_PORT;

1024} else if (type == BT_COEX_ANT_TYPE_DETECTED) {
1025gl_bt_coexist.board_info.btdm_ant_num = ant_num;
1026if (rtlpriv->cfg->mod_params->ant_sel == 1)
1027gl_bt_coexist.board_info.btdm_ant_pos =
1028BTC_ANTENNA_AT_AUX_PORT;
1029else
1030gl_bt_coexist.board_info.btdm_ant_pos =
1031BTC_ANTENNA_AT_MAIN_PORT;
1032}
1033}

The issue is that lines of code 1015-1016 and 1018-1019 are identical  
for different branches.


My question here is if one of those assignments should be modified, or  
the entire _if_ statement replaced and the function refactored?


I'd really appreciate any comment on this.

Thank you!
--
Gustavo A. R. Silva






[PATCH v2] ath10k: remove unnecessary code

2017-05-09 Thread Gustavo A. R. Silva
The array fields in struct wmi_start_scan_arg that are checked here are
fixed size arrays so they can never be NULL.

Addresses-Coverity-ID: 1260031
Cc: Arend Van Spriel <arend.vanspr...@broadcom.com>
Cc: Kalle Valo <kv...@qca.qualcomm.com>
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
Changes in v2:
 Rephrase commit log.

 drivers/net/wireless/ath/ath10k/wmi.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 2f1743e..135cf83 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -5933,15 +5933,6 @@ static struct sk_buff 
*ath10k_wmi_10_4_op_gen_init(struct ath10k *ar)
 
 int ath10k_wmi_start_scan_verify(const struct wmi_start_scan_arg *arg)
 {
-   if (arg->ie_len && !arg->ie)
-   return -EINVAL;
-   if (arg->n_channels && !arg->channels)
-   return -EINVAL;
-   if (arg->n_ssids && !arg->ssids)
-   return -EINVAL;
-   if (arg->n_bssids && !arg->bssids)
-   return -EINVAL;
-
if (arg->ie_len > WLAN_SCAN_PARAMS_MAX_IE_LEN)
return -EINVAL;
if (arg->n_channels > ARRAY_SIZE(arg->channels))
-- 
2.5.0



[PATCH v2] ath9k: remove unnecessary code

2017-05-09 Thread Gustavo A. R. Silva
The array field eeprom_data in struct th9k_platform_data
is a fixed size array so it can never be NULL.

Addresses-Coverity-ID: 1364903
Cc: Arend Van Spriel <arend.vanspr...@broadcom.com>
Cc: Kalle Valo <kv...@qca.qualcomm.com>
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
Changes in v2:
 Rephrase commit log.

 drivers/net/wireless/ath/ath9k/eeprom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c 
b/drivers/net/wireless/ath/ath9k/eeprom.c
index fb80ec8..5c3bc28 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -143,7 +143,7 @@ bool ath9k_hw_nvram_read(struct ath_hw *ah, u32 off, u16 
*data)
 
if (ah->eeprom_blob)
ret = ath9k_hw_nvram_read_firmware(ah->eeprom_blob, off, data);
-   else if (pdata && !pdata->use_eeprom && pdata->eeprom_data)
+   else if (pdata && !pdata->use_eeprom)
ret = ath9k_hw_nvram_read_pdata(pdata, off, data);
else
ret = common->bus_ops->eeprom_read(common, off, data);
-- 
2.5.0



Re: [PATCH] net: wireless: ath: ath9k: remove unnecessary code

2017-05-09 Thread Gustavo A. R. Silva


Quoting Kalle Valo <kv...@qca.qualcomm.com>:


"Gustavo A. R. Silva" <garsi...@embeddedor.com> writes:


Hi Kalle,

Quoting Kalle Valo <kv...@qca.qualcomm.com>:


"Gustavo A. R. Silva" <garsi...@embeddedor.com> writes:

The name of an array used by itself will always return the  
array's address.

So this test will always evaluate as true.

Addresses-Coverity-ID: 1364903
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/net/wireless/ath/ath9k/eeprom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c
b/drivers/net/wireless/ath/ath9k/eeprom.c
index fb80ec8..5c3bc28 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -143,7 +143,7 @@ bool ath9k_hw_nvram_read(struct ath_hw *ah, u32
off, u16 *data)

if (ah->eeprom_blob)
ret = ath9k_hw_nvram_read_firmware(ah->eeprom_blob, off, data);
-   else if (pdata && !pdata->use_eeprom && pdata->eeprom_data)
+   else if (pdata && !pdata->use_eeprom)
ret = ath9k_hw_nvram_read_pdata(pdata, off, data);
else
ret = common->bus_ops->eeprom_read(common, off, data);


The patch may very well be valid (didn't check yet) but the commit log
is gibberish for me.



Let me correct that and I'll send the patch again.


Thanks.

Also no need to have that long "net: wireless: ath:" prefix, "ath9k: "
or "ath10k: " is enough.



I get it.

Thanks!
--
Gustavo A. R. Silva








Re: [PATCH] net: wireless: ath: ath10k: remove unnecessary code

2017-05-09 Thread Gustavo A. R. Silva

Hi Arend,

Quoting Arend Van Spriel <arend.vanspr...@broadcom.com>:


On 9-5-2017 7:33, Kalle Valo wrote:

"Gustavo A. R. Silva" <garsi...@embeddedor.com> writes:


The name of an array used by itself will always return the array's address.
So these tests will always evaluate as false and therefore the _return_
will never be executed.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>


I don't understand the commit log, especially what does "The name of an
array used by itself" mean?


The array fields in struct wmi_start_scan_arg that are checked here are
fixed size arrays so they can never be NULL.

Maybe that helps rephrasing this commit message.



Definitely. Thank you!
--
Gustavo A. R. Silva








Re: [PATCH] net: wireless: ath: ath9k: remove unnecessary code

2017-05-09 Thread Gustavo A. R. Silva

Hi Kalle,

Quoting Kalle Valo <kv...@qca.qualcomm.com>:


"Gustavo A. R. Silva" <garsi...@embeddedor.com> writes:


The name of an array used by itself will always return the array's address.
So this test will always evaluate as true.

Addresses-Coverity-ID: 1364903
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/net/wireless/ath/ath9k/eeprom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c  
b/drivers/net/wireless/ath/ath9k/eeprom.c

index fb80ec8..5c3bc28 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -143,7 +143,7 @@ bool ath9k_hw_nvram_read(struct ath_hw *ah, u32  
off, u16 *data)


if (ah->eeprom_blob)
ret = ath9k_hw_nvram_read_firmware(ah->eeprom_blob, off, data);
-   else if (pdata && !pdata->use_eeprom && pdata->eeprom_data)
+   else if (pdata && !pdata->use_eeprom)
ret = ath9k_hw_nvram_read_pdata(pdata, off, data);
else
ret = common->bus_ops->eeprom_read(common, off, data);


The patch may very well be valid (didn't check yet) but the commit log
is gibberish for me.



Let me correct that and I'll send the patch again.

Thanks!
--
Gustavo A. R. Silva







Re: [PATCH] net: wireless: ath: ath10k: remove unnecessary code

2017-05-09 Thread Gustavo A. R. Silva

Hi Kalle,

Quoting Kalle Valo <kv...@qca.qualcomm.com>:


"Gustavo A. R. Silva" <garsi...@embeddedor.com> writes:


The name of an array used by itself will always return the array's address.
So these tests will always evaluate as false and therefore the _return_
will never be executed.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>


I don't understand the commit log, especially what does "The name of an
array used by itself" mean?



Let me correct that and I'll send the patch again.

Thanks!
--
Gustavo A. R. Silva








[PATCH] net: wireless: ath: ath10k: remove unnecessary code

2017-05-08 Thread Gustavo A. R. Silva
The name of an array used by itself will always return the array's address.
So these tests will always evaluate as false and therefore the _return_
will never be executed.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/net/wireless/ath/ath10k/wmi.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/wmi.c 
b/drivers/net/wireless/ath/ath10k/wmi.c
index 2f1743e..135cf83 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.c
+++ b/drivers/net/wireless/ath/ath10k/wmi.c
@@ -5933,15 +5933,6 @@ static struct sk_buff 
*ath10k_wmi_10_4_op_gen_init(struct ath10k *ar)
 
 int ath10k_wmi_start_scan_verify(const struct wmi_start_scan_arg *arg)
 {
-   if (arg->ie_len && !arg->ie)
-   return -EINVAL;
-   if (arg->n_channels && !arg->channels)
-   return -EINVAL;
-   if (arg->n_ssids && !arg->ssids)
-   return -EINVAL;
-   if (arg->n_bssids && !arg->bssids)
-   return -EINVAL;
-
if (arg->ie_len > WLAN_SCAN_PARAMS_MAX_IE_LEN)
return -EINVAL;
if (arg->n_channels > ARRAY_SIZE(arg->channels))
-- 
2.5.0



[PATCH] net: wireless: ath: ath9k: remove unnecessary code

2017-05-08 Thread Gustavo A. R. Silva
The name of an array used by itself will always return the array's address.
So this test will always evaluate as true.

Addresses-Coverity-ID: 1364903
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/net/wireless/ath/ath9k/eeprom.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c 
b/drivers/net/wireless/ath/ath9k/eeprom.c
index fb80ec8..5c3bc28 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -143,7 +143,7 @@ bool ath9k_hw_nvram_read(struct ath_hw *ah, u32 off, u16 
*data)
 
if (ah->eeprom_blob)
ret = ath9k_hw_nvram_read_firmware(ah->eeprom_blob, off, data);
-   else if (pdata && !pdata->use_eeprom && pdata->eeprom_data)
+   else if (pdata && !pdata->use_eeprom)
ret = ath9k_hw_nvram_read_pdata(pdata, off, data);
else
ret = common->bus_ops->eeprom_read(common, off, data);
-- 
2.5.0