diff mbox

qlge: pull NULL check ahead of dereference

Message ID 20100819100214.GB6674@bicker
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Dan Carpenter Aug. 19, 2010, 10:02 a.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 restore the original semantics.

Signed-off-by: Dan Carpenter <error27@gmail.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

Comments

Ron Mercer Aug. 19, 2010, 12:19 p.m. UTC | #1
On Thu, Aug 19, 2010 at 03:02:15AM -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 restore the original semantics.
>

net_rsp is initialized to NULL and will never be NULL if entries are
processed.  It should be fine as it is currently coded.

--
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
Ron Mercer Aug. 19, 2010, 12:59 p.m. UTC | #2
On Thu, Aug 19, 2010 at 05:19:42AM -0700, Ron Mercer wrote:
> On Thu, Aug 19, 2010 at 03:02:15AM -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 restore the original semantics.
> >
> 
> net_rsp is initialized to NULL and will never be NULL if entries are
> processed.  It should be fine as it is currently coded.
>

On second thought you are right but the early exit should be above the index
write.

	ql_write_cq_idx(rx_ring);

--
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..611fba4 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -2223,9 +2223,12 @@  static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
 		prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
 	}
 	ql_write_cq_idx(rx_ring);
+
+	if (!net_rsp)
+		return 0;
+
 	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)))
 			/*