From: "Michael Chan" <mchan@broadcom.com>
To: "Jeff Garzik" <jgarzik@pobox.com>
Cc: davem@davemloft.net, netdev@oss.sgi.com
Subject: Re: [PATCH 1/6] bnx2: Fix excessive stack usage
Date: Mon, 23 May 2005 21:29:16 -0700 [thread overview]
Message-ID: <1116908956.5984.4.camel@rh4> (raw)
In-Reply-To: <429286A3.1060606@pobox.com>
On Mon, 2005-05-23 at 21:42 -0400, Jeff Garzik wrote:
>
> memleak -- you need to free good_mbuf.
>
Oops, here is the revised patch with kfree(). Thanks.
Fix excessive stack usage in bnx2_alloc_bad_rbuf() by replacing local
variable array with kmalloc array. Also changed function to return error
code, and changed some of the callers to check for the return code.
Spotted by Jeff Garzik.
Signed-off-by: Michael Chan <mchan@broadcom.com>
diff -Nru 10/drivers/net/bnx2.c 11/drivers/net/bnx2.c
--- 10/drivers/net/bnx2.c 2005-05-23 10:20:02.000000000 -0700
+++ 11/drivers/net/bnx2.c 2005-05-23 21:13:46.000000000 -0700
@@ -1138,13 +1138,20 @@
}
}
-static void
+static int
bnx2_alloc_bad_rbuf(struct bnx2 *bp)
{
- u16 good_mbuf[512];
+ u16 *good_mbuf;
u32 good_mbuf_cnt;
u32 val;
+ good_mbuf = kmalloc(512 * sizeof(u16), GFP_KERNEL);
+ if (good_mbuf == NULL) {
+ printk(KERN_ERR PFX "Failed to allocate memory in "
+ "bnx2_alloc_bad_rbuf\n");
+ return -ENOMEM;
+ }
+
REG_WR(bp, BNX2_MISC_ENABLE_SET_BITS,
BNX2_MISC_ENABLE_SET_BITS_RX_MBUF_ENABLE);
@@ -1178,6 +1185,8 @@
REG_WR_IND(bp, BNX2_RBUF_FW_BUF_FREE, val);
}
+ kfree(good_mbuf);
+ return 0;
}
static void
@@ -2710,7 +2719,7 @@
bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
{
u32 val;
- int i;
+ int i, rc = 0;
/* Wait for the current PCI transaction to complete before
* issuing a reset. */
@@ -2785,10 +2794,10 @@
REG_WR(bp, BNX2_MISC_VREG_CONTROL, 0x000000fa);
/* Remove bad rbuf memory from the free pool. */
- bnx2_alloc_bad_rbuf(bp);
+ rc = bnx2_alloc_bad_rbuf(bp);
}
- return 0;
+ return rc;
}
static int
@@ -3097,8 +3106,13 @@
static int
bnx2_reset_nic(struct bnx2 *bp, u32 reset_code)
{
- bnx2_reset_chip(bp, reset_code);
+ int rc;
+
+ rc = bnx2_reset_chip(bp, reset_code);
bnx2_free_skbs(bp);
+ if (rc)
+ return rc;
+
bnx2_init_chip(bp);
bnx2_init_tx_ring(bp);
bnx2_init_rx_ring(bp);
@@ -3108,7 +3122,11 @@
static int
bnx2_init_nic(struct bnx2 *bp)
{
- bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET);
+ int rc;
+
+ if ((rc = bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET)) != 0)
+ return rc;
+
bnx2_init_phy(bp);
bnx2_set_link(bp);
return 0;
next prev parent reply other threads:[~2005-05-24 4:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-23 23:53 [PATCH 0/6] bnx2: Misc fixes Michael Chan
2005-05-24 0:25 ` [PATCH 1/6] bnx2: Fix excessive stack usage Michael Chan
2005-05-24 1:42 ` Jeff Garzik
2005-05-24 4:29 ` Michael Chan [this message]
2005-05-24 5:43 ` Jeff Garzik
2005-05-25 22:18 ` David S. Miller
2005-05-24 0:26 ` [PATCH 2/6] bnx2: Fix rx checksum Michael Chan
2005-05-24 0:27 ` [PATCH 3/6] bnx2: Fix excessive udelay Michael Chan
2005-05-24 0:29 ` [PATCH 4/6] bnx2: Fix bug in bnx2_close Michael Chan
2005-05-24 0:29 ` [PATCH 5/6] bnx2: Add bnx2 prefix and mark static Michael Chan
2005-05-24 0:30 ` [PATCH 6/6] bnx2: Update revision and reldate Michael Chan
2005-05-24 1:48 ` [PATCH 0/6] bnx2: Misc fixes Jeff Garzik
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=1116908956.5984.4.camel@rh4 \
--to=mchan@broadcom.com \
--cc=davem@davemloft.net \
--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).