From: Matt Mackall <mpm@selenic.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: netdev@oss.sgi.com
Subject: [patch] tg3 ring buffer allocation error handling
Date: Wed, 14 Apr 2004 13:46:42 -0500 [thread overview]
Message-ID: <20040414184642.GZ1175@waste.org> (raw)
tg3 - handle ring buffer allocation failure
Try to allocate rx ring buffer and properly clean up and exit on
failure.
tiny-mpm/drivers/net/tg3.c | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff -puN drivers/net/tg3.c~tg3-oops drivers/net/tg3.c
--- tiny/drivers/net/tg3.c~tg3-oops 2004-03-20 20:08:42.000000000 -0600
+++ tiny-mpm/drivers/net/tg3.c 2004-03-20 20:08:42.000000000 -0600
@@ -3092,7 +3092,7 @@ static void tg3_free_rings(struct tg3 *t
* end up in the driver. tp->{tx,}lock are held and thus
* we may not sleep.
*/
-static void tg3_init_rings(struct tg3 *tp)
+static int tg3_init_rings(struct tg3 *tp)
{
unsigned long start, end;
u32 i;
@@ -3151,18 +3151,23 @@ static void tg3_init_rings(struct tg3 *t
/* Now allocate fresh SKBs for each rx ring. */
for (i = 0; i < tp->rx_pending; i++) {
- if (tg3_alloc_rx_skb(tp, RXD_OPAQUE_RING_STD,
- -1, i) < 0)
- break;
+ if (tg3_alloc_rx_skb(tp, RXD_OPAQUE_RING_STD, -1, i) < 0) {
+ printk("tg3_alloc_rx_skb %d failed\n", i);
+ return -ENOMEM;
+ }
}
if (tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE) {
for (i = 0; i < tp->rx_jumbo_pending; i++) {
if (tg3_alloc_rx_skb(tp, RXD_OPAQUE_RING_JUMBO,
- -1, i) < 0)
- break;
+ -1, i) < 0) {
+ printk("tg3_alloc_rx_skb %d failed\n", i);
+ return -ENOMEM;
+ }
}
}
+
+ return 0;
}
/*
@@ -4557,7 +4562,9 @@ static int tg3_reset_hw(struct tg3 *tp)
* can only do this after the hardware has been
* successfully reset.
*/
- tg3_init_rings(tp);
+ err = tg3_init_rings(tp);
+ if (err)
+ return err;
/* This value is determined during the probe time DMA
* engine test, tg3_test_dma.
_
--
Matt Mackall : http://www.selenic.com : Linux development and consulting
next reply other threads:[~2004-04-14 18:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-14 18:46 Matt Mackall [this message]
2004-04-14 20:59 ` [patch] tg3 ring buffer allocation error handling Sven Schuster
2004-04-14 21:45 ` Matt Mackall
2004-04-14 22:02 ` Sven Schuster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040414184642.GZ1175@waste.org \
--to=mpm@selenic.com \
--cc=jgarzik@pobox.com \
--cc=netdev@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).