All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] qlge: pull NULL check ahead of dereference
@ 2010-08-19 10:02 ` Dan Carpenter
  0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2010-08-19 10:02 UTC (permalink / raw)
  To: Ron Mercer
  Cc: linux-driver, David S. Miller, Breno Leitao, netdev,
	kernel-janitors, ron.mercer

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>

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)))
 			/*

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [patch] qlge: pull NULL check ahead of dereference
@ 2010-08-19 10:02 ` Dan Carpenter
  0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2010-08-19 10:02 UTC (permalink / raw)
  To: Ron Mercer
  Cc: linux-driver, David S. Miller, Breno Leitao, netdev, kernel-janitors

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>

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)))
 			/*

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [patch] qlge: pull NULL check ahead of dereference
  2010-08-19 10:02 ` Dan Carpenter
@ 2010-08-19 12:19   ` Ron Mercer
  -1 siblings, 0 replies; 12+ messages in thread
From: Ron Mercer @ 2010-08-19 12:19 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Linux Driver, David S. Miller, Breno Leitao, netdev, kernel-janitors

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.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patch] qlge: pull NULL check ahead of dereference
@ 2010-08-19 12:19   ` Ron Mercer
  0 siblings, 0 replies; 12+ messages in thread
From: Ron Mercer @ 2010-08-19 12:19 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Linux Driver, David S. Miller, Breno Leitao, netdev, kernel-janitors

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.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patch] qlge: pull NULL check ahead of dereference
  2010-08-19 12:19   ` Ron Mercer
@ 2010-08-19 12:59     ` Ron Mercer
  -1 siblings, 0 replies; 12+ messages in thread
From: Ron Mercer @ 2010-08-19 12:59 UTC (permalink / raw)
  To: Dan Carpenter, Linux Driver, David S. Miller, Breno Leitao,
	netdev@vger.kernel.org

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patch] qlge: pull NULL check ahead of dereference
@ 2010-08-19 12:59     ` Ron Mercer
  0 siblings, 0 replies; 12+ messages in thread
From: Ron Mercer @ 2010-08-19 12:59 UTC (permalink / raw)
  To: Dan Carpenter, Linux Driver, David S. Miller, Breno Leitao, netdev

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [patch v2] qlge: pull NULL check ahead of dereference
  2010-08-19 12:59     ` Ron Mercer
@ 2010-08-19 18:52       ` Dan Carpenter
  -1 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2010-08-19 18:52 UTC (permalink / raw)
  To: Linux Driver, David S. Miller, Breno Leitao, netdev, 

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

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)))
 			/*

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [patch v2] qlge: pull NULL check ahead of dereference
@ 2010-08-19 18:52       ` Dan Carpenter
  0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2010-08-19 18:52 UTC (permalink / raw)
  To: Linux Driver, David S. Miller, Breno Leitao, netdev, kernel-

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

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)))
 			/*

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [patch v2] qlge: pull NULL check ahead of dereference
  2010-08-19 18:52       ` Dan Carpenter
@ 2010-08-19 20:28         ` Ron Mercer
  -1 siblings, 0 replies; 12+ messages in thread
From: Ron Mercer @ 2010-08-19 20:28 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Linux Driver, David S. Miller, Breno Leitao, netdev, kernel-janitors

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>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patch v2] qlge: pull NULL check ahead of dereference
@ 2010-08-19 20:28         ` Ron Mercer
  0 siblings, 0 replies; 12+ messages in thread
From: Ron Mercer @ 2010-08-19 20:28 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Linux Driver, David S. Miller, Breno Leitao, netdev, kernel-janitors

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>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patch v2] qlge: pull NULL check ahead of dereference
  2010-08-19 20:28         ` Ron Mercer
@ 2010-08-20  3:48           ` David Miller
  -1 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2010-08-20  3:48 UTC (permalink / raw)
  To: ron.mercer; +Cc: error27, Linux-Driver, leitao, netdev, kernel-janitors

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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [patch v2] qlge: pull NULL check ahead of dereference
@ 2010-08-20  3:48           ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2010-08-20  3:48 UTC (permalink / raw)
  To: ron.mercer; +Cc: error27, Linux-Driver, leitao, netdev, kernel-janitors

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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-08-20  3:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-19 10:02 [patch] qlge: pull NULL check ahead of dereference Dan Carpenter
2010-08-19 10:02 ` Dan Carpenter
2010-08-19 12:19 ` Ron Mercer
2010-08-19 12:19   ` Ron Mercer
2010-08-19 12:59   ` Ron Mercer
2010-08-19 12:59     ` Ron Mercer
2010-08-19 18:52     ` [patch v2] " Dan Carpenter
2010-08-19 18:52       ` Dan Carpenter
2010-08-19 20:28       ` Ron Mercer
2010-08-19 20:28         ` Ron Mercer
2010-08-20  3:48         ` David Miller
2010-08-20  3:48           ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.