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]>