From: Simon Goldschmidt Date: Fri, 12 Jul 2019 18:58:18 +0000 (+0200) Subject: cmd: mdio: prevent data abort when no mdio bus is found X-Git-Tag: v2019.10-rc1~23^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb58d18beb3cd65b66c20f913cb55c38c322457b;p=platform%2Fkernel%2Fu-boot.git cmd: mdio: prevent data abort when no mdio bus is found Calling 'mdio read ...' currently leads to a data abort when no mdio bus is found. To fix this, check if 'bus' is a valid pointer before accessing it. Signed-off-by: Simon Goldschmidt Tested-by: Vladimir Oltean Reviewed-by: Vladimir Oltean Acked-by: Joe Hershberger --- diff --git a/cmd/mdio.c b/cmd/mdio.c index a6fa926..add6440 100644 --- a/cmd/mdio.c +++ b/cmd/mdio.c @@ -268,6 +268,11 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) break; } + if (!bus) { + puts("No MDIO bus found\n"); + return CMD_RET_FAILURE; + } + if (op[0] == 'l') { mdio_list_devices();