]> Git Repo - J-u-boot.git/commit - common/miiphyutil.c
common: miiphyutil: avoid memory leak
authorPeng Fan <[email protected]>
Thu, 26 Nov 2015 02:26:59 +0000 (10:26 +0800)
committerTom Rini <[email protected]>
Sat, 5 Dec 2015 23:22:24 +0000 (18:22 -0500)
commit746da1bd42aa5ecc47898399514c9c76d0329706
tree43b3dbb21a9c804bfd52a390aede9bbdc4e203b9
parent678e9316d48f78d162f705846b6f6eeab4aa5dd0
common: miiphyutil: avoid memory leak

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 <[email protected]>
Cc: Joe Hershberger <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Bin Meng <[email protected]>
Reviewed-by: Bin Meng <[email protected]>
Acked-by: Joe Hershberger <[email protected]>
common/miiphyutil.c
This page took 0.034513 seconds and 4 git commands to generate.