From: Joe Perches <joe@perches.com>
To: Jesper Juhl <jj@chaosbits.net>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"John(Zongxi) Chen" <zongxi@broadcom.com>,
Michael Chan <mchan@broadcom.com>
Subject: Re: [PATCH] Broadcom CNIC core network driver: fix mem leak on allocation failures in cnic_alloc_uio_rings()
Date: Sun, 26 Dec 2010 12:54:10 -0800 [thread overview]
Message-ID: <1293396850.7726.14.camel@Joe-Laptop> (raw)
In-Reply-To: <alpine.LNX.2.00.1012262124320.20797@swampdragon.chaosbits.net>
On Sun, 2010-12-26 at 21:30 +0100, Jesper Juhl wrote:
> We are leaking memory in drivers/net/cnic.c::cnic_alloc_uio_rings() if
> either of the calls to dma_alloc_coherent() fail.
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> cnic.c | 10 ++++++++--
> diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
[]
> - if (!udev->l2_ring)
> + if (!udev->l2_ring) {
> + kfree(udev);
> return -ENOMEM;
> + }
[]
> - if (!udev->l2_buf)
> + if (!udev->l2_buf) {
> + dma_free_coherent(&udev->pdev->dev, udev->l2_ring_size,
> + udev->l2_ring, udev->l2_ring_map);
> + kfree(udev);
> return -ENOMEM;
> + }
Perhaps this would be more standard with a goto error / exit block
err_dma:
dma_free_coherent();
err_udev:
kfree(udev);
return -ENOMEM;
next prev parent reply other threads:[~2010-12-26 20:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-26 20:30 [PATCH] Broadcom CNIC core network driver: fix mem leak on allocation failures in cnic_alloc_uio_rings() Jesper Juhl
2010-12-26 20:54 ` Joe Perches [this message]
2010-12-26 20:57 ` [PATCH v2] " Jesper Juhl
2010-12-27 3:57 ` Michael Chan
2010-12-31 19:20 ` David Miller
2011-01-02 18:54 ` Jesper Juhl
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=1293396850.7726.14.camel@Joe-Laptop \
--to=joe@perches.com \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mchan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=zongxi@broadcom.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