diff mbox

[1/2] ath: Fix ath_dbg uses missing newlines and access beyond array bound

Message ID 276469c602c402565b49f99521ea19757429e81e.1291266731.git.joe@perches.com
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Joe Perches Dec. 2, 2010, 5:13 a.m. UTC
Add missing newlines to ath_dbg uses
ar9300RateSize is not a power of 4, fix to print array line by line.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/wireless/ath/ath9k/ar9003_eeprom.c |   29 ++---------------------
 drivers/net/wireless/ath/ath9k/calib.c         |    4 +-
 drivers/net/wireless/ath/ath9k/gpio.c          |    6 ++--
 drivers/net/wireless/ath/ath9k/htc_drv_gpio.c  |    7 ++---
 drivers/net/wireless/ath/ath9k/htc_drv_main.c  |    2 +-
 5 files changed, 12 insertions(+), 36 deletions(-)

Comments

Luis R. Rodriguez Dec. 2, 2010, 7:02 p.m. UTC | #1
On Wed, Dec 01, 2010 at 09:13:32PM -0800, Joe Perches wrote:
> Add missing newlines to ath_dbg uses
> ar9300RateSize is not a power of 4, fix to print array line by line.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  drivers/net/wireless/ath/ath9k/ar9003_eeprom.c |   29 ++---------------------
>  drivers/net/wireless/ath/ath9k/calib.c         |    4 +-
>  drivers/net/wireless/ath/ath9k/gpio.c          |    6 ++--
>  drivers/net/wireless/ath/ath9k/htc_drv_gpio.c  |    7 ++---
>  drivers/net/wireless/ath/ath9k/htc_drv_main.c  |    2 +-
>  5 files changed, 12 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
> index e6ae62b..beb3e87 100644
> --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
> +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
> @@ -3342,7 +3342,7 @@ static int ar9300_eeprom_restore_internal(struct ath_hw *ah,
>  	goto fail;
>  
>  found:
> -	ath_dbg(common, ATH_DBG_EEPROM, "Found valid EEPROM data");
> +	ath_dbg(common, ATH_DBG_EEPROM, "Found valid EEPROM data\n");
>  
>  	for (it = 0; it < MSTATE; it++) {
>  		if (!read(ah, cptr, word, COMP_HDR_LEN))
> @@ -4084,22 +4084,9 @@ static void ar9003_hw_set_target_power_eeprom(struct ath_hw *ah, u16 freq,
>  	    ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_23, freq,
>  					      is2GHz) + ht40PowerIncForPdadc;
>  
> -	while (i < ar9300RateSize) {
> -		ath_dbg(common, ATH_DBG_EEPROM,
> -			"TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
> -		i++;
> -
> -		ath_dbg(common, ATH_DBG_EEPROM,
> -			"TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
> -		i++;
> -
> -		ath_dbg(common, ATH_DBG_EEPROM,
> -			"TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
> -		i++;
> -
> +	for (i = 0; i < ar9300RateSize; i++) {
>  		ath_dbg(common, ATH_DBG_EEPROM,
>  			"TPC[%02d] 0x%08x\n", i, targetPowerValT2[i]);
> -		i++;
>  	}
>  }

Please send this hunk on a separate patch.

  Luis
 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Joe Perches Dec. 3, 2010, 3:12 a.m. UTC | #2
ath_print is misleading as it's only used with CONFIG_ATH_DEBUG.

Add and use the more normal <subsystem>_printk and <subsystem>_<level>
printk equivalents. (ath_printk and ath_<level>)

Fix various defects in the current uses of ath_print formats
and arguments: Unnecessary casts, missing newlines, multiple
prints, and 1 loop which can exceed array bounds.

Bundled and integrated the individual patches into a single patch series.

Joe Perches (4):
  ath: Add and use ath_printk and ath_<level>
  ath: Convert ath_print(.., ATH_DBG_FATAL to ath_err
  ath: Convert ath_print to ath_dbg
  ath: Fix ath_dbg access beyond array bound

 drivers/net/wireless/ath/ath.h                  |  103 +++++++++++
 drivers/net/wireless/ath/ath5k/base.c           |    1 -
 drivers/net/wireless/ath/ath5k/debug.c          |    1 -
 drivers/net/wireless/ath/ath9k/ahb.c            |    7 +-
 drivers/net/wireless/ath/ath9k/ani.c            |   97 +++++------
 drivers/net/wireless/ath/ath9k/ar5008_phy.c     |  199 +++++++++------------
 drivers/net/wireless/ath/ath9k/ar9002_calib.c   |  220 +++++++++++------------
 drivers/net/wireless/ath/ath9k/ar9002_hw.c      |    6 +-
 drivers/net/wireless/ath/ath9k/ar9002_mac.c     |   20 +-
 drivers/net/wireless/ath/ath9k/ar9003_calib.c   |  217 +++++++++++-----------
 drivers/net/wireless/ath/ath9k/ar9003_eeprom.c  |  174 ++++++++-----------
 drivers/net/wireless/ath/ath9k/ar9003_mac.c     |   16 +-
 drivers/net/wireless/ath/ath9k/ar9003_phy.c     |  205 ++++++++++-----------
 drivers/net/wireless/ath/ath9k/beacon.c         |   79 ++++-----
 drivers/net/wireless/ath/ath9k/calib.c          |   59 +++---
 drivers/net/wireless/ath/ath9k/common.c         |    4 +-
 drivers/net/wireless/ath/ath9k/common.h         |    1 -
 drivers/net/wireless/ath/ath9k/eeprom.c         |    4 +-
 drivers/net/wireless/ath/ath9k/eeprom_4k.c      |   72 ++++----
 drivers/net/wireless/ath/ath9k/eeprom_9287.c    |   39 ++---
 drivers/net/wireless/ath/ath9k/eeprom_def.c     |   67 ++++----
 drivers/net/wireless/ath/ath9k/gpio.c           |   20 +-
 drivers/net/wireless/ath/ath9k/htc_drv_beacon.c |   24 ++--
 drivers/net/wireless/ath/ath9k/htc_drv_gpio.c   |   15 +-
 drivers/net/wireless/ath/ath9k/htc_drv_init.c   |   63 +++----
 drivers/net/wireless/ath/ath9k/htc_drv_main.c   |  192 ++++++++++----------
 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c   |   33 ++--
 drivers/net/wireless/ath/ath9k/hw.c             |  161 ++++++++---------
 drivers/net/wireless/ath/ath9k/hw.h             |    1 -
 drivers/net/wireless/ath/ath9k/init.c           |   28 ++--
 drivers/net/wireless/ath/ath9k/mac.c            |  117 ++++++-------
 drivers/net/wireless/ath/ath9k/main.c           |  185 +++++++++----------
 drivers/net/wireless/ath/ath9k/pci.c            |    7 +-
 drivers/net/wireless/ath/ath9k/rc.c             |   18 +-
 drivers/net/wireless/ath/ath9k/recv.c           |   48 +++---
 drivers/net/wireless/ath/ath9k/virtual.c        |    7 +-
 drivers/net/wireless/ath/ath9k/wmi.c            |   12 +-
 drivers/net/wireless/ath/ath9k/xmit.c           |   84 ++++-----
 drivers/net/wireless/ath/debug.c                |   20 --
 drivers/net/wireless/ath/debug.h                |   92 ----------
 drivers/net/wireless/ath/key.c                  |   28 ++--
 drivers/net/wireless/ath/main.c                 |   20 ++
 42 files changed, 1306 insertions(+), 1460 deletions(-)
 delete mode 100644 drivers/net/wireless/ath/debug.h
John W. Linville Dec. 7, 2010, 7:05 p.m. UTC | #3
On Thu, Dec 02, 2010 at 07:12:34PM -0800, Joe Perches wrote:
> ath_print is misleading as it's only used with CONFIG_ATH_DEBUG.
> 
> Add and use the more normal <subsystem>_printk and <subsystem>_<level>
> printk equivalents. (ath_printk and ath_<level>)
> 
> Fix various defects in the current uses of ath_print formats
> and arguments: Unnecessary casts, missing newlines, multiple
> prints, and 1 loop which can exceed array bounds.
> 
> Bundled and integrated the individual patches into a single patch series.
> 
> Joe Perches (4):
>   ath: Add and use ath_printk and ath_<level>
>   ath: Convert ath_print(.., ATH_DBG_FATAL to ath_err
>   ath: Convert ath_print to ath_dbg
>   ath: Fix ath_dbg access beyond array bound

Is the Atheros crew happy with this series?  They didn't seem to like
the original patches very much...

John
Luis R. Rodriguez Dec. 7, 2010, 7:26 p.m. UTC | #4
On Tue, Dec 07, 2010 at 11:05:28AM -0800, John W. Linville wrote:
> On Thu, Dec 02, 2010 at 07:12:34PM -0800, Joe Perches wrote:
> > ath_print is misleading as it's only used with CONFIG_ATH_DEBUG.
> > 
> > Add and use the more normal <subsystem>_printk and <subsystem>_<level>
> > printk equivalents. (ath_printk and ath_<level>)
> > 
> > Fix various defects in the current uses of ath_print formats
> > and arguments: Unnecessary casts, missing newlines, multiple
> > prints, and 1 loop which can exceed array bounds.
> > 
> > Bundled and integrated the individual patches into a single patch series.
> > 
> > Joe Perches (4):
> >   ath: Add and use ath_printk and ath_<level>
> >   ath: Convert ath_print(.., ATH_DBG_FATAL to ath_err
> >   ath: Convert ath_print to ath_dbg
> >   ath: Fix ath_dbg access beyond array bound
> 
> Is the Atheros crew happy with this series?  They didn't seem to like
> the original patches very much...

Its fine now that Joe has addressed some more important items.
But I'd like for the patches to be applied last of all pending
patches :)

  Luis
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index e6ae62b..beb3e87 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -3342,7 +3342,7 @@  static int ar9300_eeprom_restore_internal(struct ath_hw *ah,
 	goto fail;
 
 found:
-	ath_dbg(common, ATH_DBG_EEPROM, "Found valid EEPROM data");
+	ath_dbg(common, ATH_DBG_EEPROM, "Found valid EEPROM data\n");
 
 	for (it = 0; it < MSTATE; it++) {
 		if (!read(ah, cptr, word, COMP_HDR_LEN))
@@ -4084,22 +4084,9 @@  static void ar9003_hw_set_target_power_eeprom(struct ath_hw *ah, u16 freq,
 	    ar9003_hw_eeprom_get_ht40_tgt_pwr(ah, HT_TARGET_RATE_23, freq,
 					      is2GHz) + ht40PowerIncForPdadc;
 
-	while (i < ar9300RateSize) {
-		ath_dbg(common, ATH_DBG_EEPROM,
-			"TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
-		i++;
-
-		ath_dbg(common, ATH_DBG_EEPROM,
-			"TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
-		i++;
-
-		ath_dbg(common, ATH_DBG_EEPROM,
-			"TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
-		i++;
-
+	for (i = 0; i < ar9300RateSize; i++) {
 		ath_dbg(common, ATH_DBG_EEPROM,
 			"TPC[%02d] 0x%08x\n", i, targetPowerValT2[i]);
-		i++;
 	}
 }
 
@@ -4687,17 +4674,7 @@  static void ath9k_hw_ar9300_set_txpower(struct ath_hw *ah,
 
 	for (i = 0; i < ar9300RateSize; i++) {
 		ath_dbg(common, ATH_DBG_EEPROM,
-			"TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
-		i++;
-		ath_dbg(common, ATH_DBG_EEPROM,
-			"TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
-		i++;
-		ath_dbg(common, ATH_DBG_EEPROM,
-			"TPC[%02d] 0x%08x ", i, targetPowerValT2[i]);
-		i++;
-		ath_dbg(common, ATH_DBG_EEPROM,
-			"TPC[%02d] 0x%08x\n\n", i, targetPowerValT2[i]);
-		i++;
+			"TPC[%02d] 0x%08x\n", i, targetPowerValT2[i]);
 	}
 
 	/*
diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
index 0b6c623..b68a1ac 100644
--- a/drivers/net/wireless/ath/ath9k/calib.c
+++ b/drivers/net/wireless/ath/ath9k/calib.c
@@ -324,12 +324,12 @@  static void ath9k_hw_nf_sanitize(struct ath_hw *ah, s16 *nf)
 
 		if (nf[i] > ATH9K_NF_TOO_HIGH) {
 			ath_dbg(common, ATH_DBG_CALIBRATE,
-				"NF[%d] (%d) > MAX (%d), correcting to MAX",
+				"NF[%d] (%d) > MAX (%d), correcting to MAX\n",
 				i, nf[i], ATH9K_NF_TOO_HIGH);
 			nf[i] = limit->max;
 		} else if (nf[i] < limit->min) {
 			ath_dbg(common, ATH_DBG_CALIBRATE,
-				"NF[%d] (%d) < MIN (%d), correcting to NOM",
+				"NF[%d] (%d) < MIN (%d), correcting to NOM\n",
 				i, nf[i], limit->min);
 			nf[i] = limit->nominal;
 		}
diff --git a/drivers/net/wireless/ath/ath9k/gpio.c b/drivers/net/wireless/ath/ath9k/gpio.c
index 60b2fb7..1337640 100644
--- a/drivers/net/wireless/ath/ath9k/gpio.c
+++ b/drivers/net/wireless/ath/ath9k/gpio.c
@@ -237,12 +237,12 @@  static void ath_detect_bt_priority(struct ath_softc *sc)
 		/* Detect if colocated bt started scanning */
 		if (btcoex->bt_priority_cnt >= ATH_BT_CNT_SCAN_THRESHOLD) {
 			ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_BTCOEX,
-				"BT scan detected");
+				"BT scan detected\n");
 			sc->sc_flags |= (SC_OP_BT_SCAN |
 					 SC_OP_BT_PRIORITY_DETECTED);
 		} else if (btcoex->bt_priority_cnt >= ATH_BT_CNT_THRESHOLD) {
 			ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_BTCOEX,
-				"BT priority traffic detected");
+				"BT priority traffic detected\n");
 			sc->sc_flags |= SC_OP_BT_PRIORITY_DETECTED;
 		}
 
@@ -379,7 +379,7 @@  void ath9k_btcoex_timer_resume(struct ath_softc *sc)
 	struct ath_hw *ah = sc->sc_ah;
 
 	ath_dbg(ath9k_hw_common(ah), ATH_DBG_BTCOEX,
-		"Starting btcoex timers");
+		"Starting btcoex timers\n");
 
 	/* make sure duty cycle timer is also stopped when resuming */
 	if (btcoex->hw_timer_enabled)
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c b/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c
index d8685f0..283ff97 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_gpio.c
@@ -21,12 +21,12 @@  static void ath_detect_bt_priority(struct ath9k_htc_priv *priv)
 		/* Detect if colocated bt started scanning */
 		if (btcoex->bt_priority_cnt >= ATH_BT_CNT_SCAN_THRESHOLD) {
 			ath_dbg(ath9k_hw_common(ah), ATH_DBG_BTCOEX,
-				"BT scan detected");
+				"BT scan detected\n");
 			priv->op_flags |= (OP_BT_SCAN |
 					 OP_BT_PRIORITY_DETECTED);
 		} else if (btcoex->bt_priority_cnt >= ATH_BT_CNT_THRESHOLD) {
 			ath_dbg(ath9k_hw_common(ah), ATH_DBG_BTCOEX,
-				"BT priority traffic detected");
+				"BT priority traffic detected\n");
 			priv->op_flags |= OP_BT_PRIORITY_DETECTED;
 		}
 
@@ -114,8 +114,7 @@  void ath_htc_resume_btcoex_work(struct ath9k_htc_priv *priv)
 	struct ath_btcoex *btcoex = &priv->btcoex;
 	struct ath_hw *ah = priv->ah;
 
-	ath_dbg(ath9k_hw_common(ah), ATH_DBG_BTCOEX,
-		"Starting btcoex work");
+	ath_dbg(ath9k_hw_common(ah), ATH_DBG_BTCOEX, "Starting btcoex work\n");
 
 	btcoex->bt_priority_cnt = 0;
 	btcoex->bt_priority_time = jiffies;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index 1af31b5..87731c2 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -1133,7 +1133,7 @@  static int ath9k_htc_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
 			spin_unlock_bh(&priv->tx_lock);
 		} else {
 			ath_dbg(ath9k_hw_common(priv->ah), ATH_DBG_XMIT,
-				"Tx failed");
+				"Tx failed\n");
 		}
 		goto fail_tx;
 	}