diff mbox

[v2] qlge: pull NULL check ahead of dereference

Message ID 20100819185244.GD6674@bicker
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Dan Carpenter Aug. 19, 2010, 6:52 p.m. UTC
There was a dereference before NULL check issue introduced in 1e213303d
"qlge: Add tx multiqueue support."  I've pulled the NULL check of
"net_rsp" forward a couple lines to avoid that.

Also Ron Mercer says that the early exit should be above the index
write.  ql_write_cq_idx(rx_ring);

Signed-off-by: Dan Carpenter <error27@gmail.com>
---
v2: Moved the early exit ahead of the ql_write_cq_idx()

--
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

Comments

Ron Mercer Aug. 19, 2010, 8:28 p.m. UTC | #1
On Thu, Aug 19, 2010 at 11:52:44AM -0700, Dan Carpenter wrote:
> There was a dereference before NULL check issue introduced in 1e213303d
> "qlge: Add tx multiqueue support."  I've pulled the NULL check of
> "net_rsp" forward a couple lines to avoid that.
> 
> Also Ron Mercer says that the early exit should be above the index
> write.  ql_write_cq_idx(rx_ring);
> 

Signed-off-by: Ron Mercer <ron.mercer@qlogic.com>
--
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
David Miller Aug. 20, 2010, 3:48 a.m. UTC | #2
From: Ron Mercer <ron.mercer@qlogic.com>
Date: Thu, 19 Aug 2010 13:28:36 -0700

> On Thu, Aug 19, 2010 at 11:52:44AM -0700, Dan Carpenter wrote:
>> There was a dereference before NULL check issue introduced in 1e213303d
>> "qlge: Add tx multiqueue support."  I've pulled the NULL check of
>> "net_rsp" forward a couple lines to avoid that.
>> 
>> Also Ron Mercer says that the early exit should be above the index
>> write.  ql_write_cq_idx(rx_ring);
>> 
> 
> Signed-off-by: Ron Mercer <ron.mercer@qlogic.com>

Applied to net-next-2.6, thanks guys.
--
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/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index 8d63f69..c9f9754 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -2222,10 +2222,11 @@  static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
 		ql_update_cq(rx_ring);
 		prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
 	}
+	if (!net_rsp)
+		return 0;
 	ql_write_cq_idx(rx_ring);
 	tx_ring = &qdev->tx_ring[net_rsp->txq_idx];
-	if (__netif_subqueue_stopped(qdev->ndev, tx_ring->wq_id) &&
-					net_rsp != NULL) {
+	if (__netif_subqueue_stopped(qdev->ndev, tx_ring->wq_id)) {
 		if (atomic_read(&tx_ring->queue_stopped) &&
 		    (atomic_read(&tx_ring->tx_count) > (tx_ring->wq_len / 4)))
 			/*