[U-Boot] common: miiphyutil: avoid memory leak

Tom Rini trini at konsulko.com
Sun Dec 6 23:06:41 CET 2015


On Thu, Nov 26, 2015 at 10:26:59AM +0800, Peng Fan wrote:

> The following code will alloc memory for new_dev and ldev:
> "
> new_dev = mdio_alloc();
> ldev = malloc(sizeof(*ldev));
> "
> Either new_dev or ldev is NULL, directly return, but this may leak memory.
> So before return, using free(ldev) and mdio_free(new_dev) to avoid
> leaking memory, also free can handle NULL pointer.
> 
> Signed-off-by: Peng Fan <Peng.Fan at freescale.com>
> Cc: Joe Hershberger <joe.hershberger at ni.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Bin Meng <bmeng.cn at gmail.com>
> Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> Acked-by: Joe Hershberger <joe.hershberger at ni.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151206/d3298017/attachment.sig>


More information about the U-Boot mailing list