[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1293396850.7726.14.camel@Joe-Laptop>
Date: Sun, 26 Dec 2010 12:54:10 -0800
From: Joe Perches <joe@...ches.com>
To: Jesper Juhl <jj@...osbits.net>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
"John(Zongxi) Chen" <zongxi@...adcom.com>,
Michael Chan <mchan@...adcom.com>
Subject: Re: [PATCH] Broadcom CNIC core network driver: fix mem leak on
allocation failures in cnic_alloc_uio_rings()
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@...osbits.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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists