[U-Boot] [PATCH] common: miiphyutil: avoid memory leak
Joe Hershberger
joe.hershberger at gmail.com
Mon Nov 30 21:34:36 CET 2015
Hi Peng
On Wed, Nov 25, 2015 at 8:26 PM, Peng Fan <Peng.Fan at freescale.com> 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>
Acked-by: Joe Hershberger <joe.hershberger at ni.com>
More information about the U-Boot
mailing list