* [PATCH] bnx2: do not start the interface if reset fails
@ 2011-07-13 17:54 Flavio Leitner
2011-07-15 0:06 ` David Miller
2011-07-15 0:13 ` Michael Chan
0 siblings, 2 replies; 3+ messages in thread
From: Flavio Leitner @ 2011-07-13 17:54 UTC (permalink / raw)
To: netdev, Michael Chan; +Cc: Flavio Leitner
When bnx2_reset_task() is called, it will stop,
(re)initialize and start the interface to restore
the working condition.
The bnx2_init_nic() calls bnx2_reset_nic() which will
reset the chip and then call bnx2_free_skbs() to free
all the skbs.
The problem happens when bnx2_init_chip() fails because
bnx2_reset_nic() will just return skipping the ring
initializations at bnx2_init_all_rings(). Later, the
reset task starts the interface again and the system
crashes due a NULL pointer access (no skb in the ring).
This patch just check the return code and if an error is
reported, warn the user and abort. It's better to have a
non working interface than a crash.
Signed-off-by: Flavio Leitner <fbl@redhat.com>
---
drivers/net/bnx2.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 7915d14..7fb71fc 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -6296,6 +6296,7 @@ static void
bnx2_reset_task(struct work_struct *work)
{
struct bnx2 *bp = container_of(work, struct bnx2, reset_task);
+ int rc;
rtnl_lock();
if (!netif_running(bp->dev)) {
@@ -6305,10 +6306,15 @@ bnx2_reset_task(struct work_struct *work)
bnx2_netif_stop(bp, true);
- bnx2_init_nic(bp, 1);
+ rc = bnx2_init_nic(bp, 1);
+ if (rc) {
+ netdev_err(bp->dev, "failed to reset the NIC, aborting\n");
+ goto out;
+ }
atomic_set(&bp->intr_sem, 1);
bnx2_netif_start(bp, true);
+out:
rtnl_unlock();
}
--
1.7.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bnx2: do not start the interface if reset fails
2011-07-13 17:54 [PATCH] bnx2: do not start the interface if reset fails Flavio Leitner
@ 2011-07-15 0:06 ` David Miller
2011-07-15 0:13 ` Michael Chan
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2011-07-15 0:06 UTC (permalink / raw)
To: fbl; +Cc: netdev, mchan
From: Flavio Leitner <fbl@redhat.com>
Date: Wed, 13 Jul 2011 14:54:50 -0300
> When bnx2_reset_task() is called, it will stop,
> (re)initialize and start the interface to restore
> the working condition.
>
> The bnx2_init_nic() calls bnx2_reset_nic() which will
> reset the chip and then call bnx2_free_skbs() to free
> all the skbs.
>
> The problem happens when bnx2_init_chip() fails because
> bnx2_reset_nic() will just return skipping the ring
> initializations at bnx2_init_all_rings(). Later, the
> reset task starts the interface again and the system
> crashes due a NULL pointer access (no skb in the ring).
>
> This patch just check the return code and if an error is
> reported, warn the user and abort. It's better to have a
> non working interface than a crash.
>
> Signed-off-by: Flavio Leitner <fbl@redhat.com>
Broadcom folks?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bnx2: do not start the interface if reset fails
2011-07-13 17:54 [PATCH] bnx2: do not start the interface if reset fails Flavio Leitner
2011-07-15 0:06 ` David Miller
@ 2011-07-15 0:13 ` Michael Chan
1 sibling, 0 replies; 3+ messages in thread
From: Michael Chan @ 2011-07-15 0:13 UTC (permalink / raw)
To: Flavio Leitner; +Cc: netdev
On Wed, 2011-07-13 at 10:54 -0700, Flavio Leitner wrote:
> When bnx2_reset_task() is called, it will stop,
> (re)initialize and start the interface to restore
> the working condition.
>
> The bnx2_init_nic() calls bnx2_reset_nic() which will
> reset the chip and then call bnx2_free_skbs() to free
> all the skbs.
>
> The problem happens when bnx2_init_chip() fails because
> bnx2_reset_nic() will just return skipping the ring
> initializations at bnx2_init_all_rings(). Later, the
> reset task starts the interface again and the system
> crashes due a NULL pointer access (no skb in the ring).
>
> This patch just check the return code and if an error is
> reported, warn the user and abort. It's better to have a
> non working interface than a crash.
>
> Signed-off-by: Flavio Leitner <fbl@redhat.com>
> ---
> drivers/net/bnx2.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
> index 7915d14..7fb71fc 100644
> --- a/drivers/net/bnx2.c
> +++ b/drivers/net/bnx2.c
> @@ -6296,6 +6296,7 @@ static void
> bnx2_reset_task(struct work_struct *work)
> {
> struct bnx2 *bp = container_of(work, struct bnx2, reset_task);
> + int rc;
>
> rtnl_lock();
> if (!netif_running(bp->dev)) {
> @@ -6305,10 +6306,15 @@ bnx2_reset_task(struct work_struct *work)
>
> bnx2_netif_stop(bp, true);
>
> - bnx2_init_nic(bp, 1);
> + rc = bnx2_init_nic(bp, 1);
> + if (rc) {
> + netdev_err(bp->dev, "failed to reset the NIC, aborting\n");
> + goto out;
> + }
I think it is better to call dev_close() instead. I'll post a patch
soon. Thanks.
>
> atomic_set(&bp->intr_sem, 1);
> bnx2_netif_start(bp, true);
> +out:
> rtnl_unlock();
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-07-15 0:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-13 17:54 [PATCH] bnx2: do not start the interface if reset fails Flavio Leitner
2011-07-15 0:06 ` David Miller
2011-07-15 0:13 ` Michael Chan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).