From cb58d18beb3cd65b66c20f913cb55c38c322457b Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Fri, 12 Jul 2019 20:58:18 +0200 Subject: 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 --- cmd/mdio.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'cmd') 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(); -- cgit