aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>2014-03-02 04:20:50 -0500
committerJohn W. Linville <linville@tuxdriver.com>2014-03-03 15:35:56 -0500
commitaf31cb5a57084146aae5c01df6b85f54067528aa (patch)
treec797949b4b24e2af50a5d54ccbc9c0400c70a575
parent7661e97542d57d54317407ff4790e2d6d94a0852 (diff)
wil6210: fix buffer overflow in wil_txdesc_debugfs_show()
Wrong index comparison logic, found by smatch: drivers/net/wireless/ath/wil6210/debugfs.c:402 wil_txdesc_debugfs_show() warn: buffer overflow 'wil->vring_tx' 24 <= 24 Signed-off-by: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/wil6210/debugfs.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c
index 729e774ee96d..1d09a4b0a0f4 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -26,8 +26,7 @@
26/* Nasty hack. Better have per device instances */ 26/* Nasty hack. Better have per device instances */
27static u32 mem_addr; 27static u32 mem_addr;
28static u32 dbg_txdesc_index; 28static u32 dbg_txdesc_index;
29static u32 dbg_vring_index; /* 25 for Rx, 0..24 for Tx */ 29static u32 dbg_vring_index; /* 24+ for Rx, 0..23 for Tx */
30#define WIL_DBG_VRING_INDEX_RX (WIL6210_MAX_TX_RINGS + 1)
31 30
32static void wil_print_vring(struct seq_file *s, struct wil6210_priv *wil, 31static void wil_print_vring(struct seq_file *s, struct wil6210_priv *wil,
33 const char *name, struct vring *vring, 32 const char *name, struct vring *vring,
@@ -404,13 +403,14 @@ static int wil_txdesc_debugfs_show(struct seq_file *s, void *data)
404{ 403{
405 struct wil6210_priv *wil = s->private; 404 struct wil6210_priv *wil = s->private;
406 struct vring *vring; 405 struct vring *vring;
407 if (dbg_vring_index <= WIL6210_MAX_TX_RINGS) 406 bool tx = (dbg_vring_index < WIL6210_MAX_TX_RINGS);
407 if (tx)
408 vring = &(wil->vring_tx[dbg_vring_index]); 408 vring = &(wil->vring_tx[dbg_vring_index]);
409 else 409 else
410 vring = &wil->vring_rx; 410 vring = &wil->vring_rx;
411 411
412 if (!vring->va) { 412 if (!vring->va) {
413 if (dbg_vring_index <= WIL6210_MAX_TX_RINGS) 413 if (tx)
414 seq_printf(s, "No Tx[%2d] VRING\n", dbg_vring_index); 414 seq_printf(s, "No Tx[%2d] VRING\n", dbg_vring_index);
415 else 415 else
416 seq_puts(s, "No Rx VRING\n"); 416 seq_puts(s, "No Rx VRING\n");
@@ -426,7 +426,7 @@ static int wil_txdesc_debugfs_show(struct seq_file *s, void *data)
426 volatile u32 *u = (volatile u32 *)d; 426 volatile u32 *u = (volatile u32 *)d;
427 struct sk_buff *skb = vring->ctx[dbg_txdesc_index].skb; 427 struct sk_buff *skb = vring->ctx[dbg_txdesc_index].skb;
428 428
429 if (dbg_vring_index <= WIL6210_MAX_TX_RINGS) 429 if (tx)
430 seq_printf(s, "Tx[%2d][%3d] = {\n", dbg_vring_index, 430 seq_printf(s, "Tx[%2d][%3d] = {\n", dbg_vring_index,
431 dbg_txdesc_index); 431 dbg_txdesc_index);
432 else 432 else
@@ -461,7 +461,7 @@ static int wil_txdesc_debugfs_show(struct seq_file *s, void *data)
461 } 461 }
462 seq_printf(s, "}\n"); 462 seq_printf(s, "}\n");
463 } else { 463 } else {
464 if (dbg_vring_index <= WIL6210_MAX_TX_RINGS) 464 if (tx)
465 seq_printf(s, "[%2d] TxDesc index (%d) >= size (%d)\n", 465 seq_printf(s, "[%2d] TxDesc index (%d) >= size (%d)\n",
466 dbg_vring_index, dbg_txdesc_index, 466 dbg_vring_index, dbg_txdesc_index,
467 vring->size); 467 vring->size);