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-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=cb58d18beb3cd65b66c20f913cb55c38c322457b;p=u-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 a6fa9266d0..add6440813 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();