Commit 1a07d4585b0497f54bf2d127e5fb8ba7cfa2958a
Committed by
guoyin.chen
1 parent
bc26ac4615
Exists in
smarc-imx_v2015.04_4.1.15_1.0.0_ga
and in
1 other branch
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 <Peng.Fan@freescale.com> Cc: Joe Hershberger <joe.hershberger@ni.com> Cc: Simon Glass <sjg@chromium.org> Cc: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com> (cherry picked from commit 746da1bd42aa5ecc47898399514c9c76d0329706)
Showing 1 changed file with 2 additions and 0 deletions Side-by-side Diff