summaryrefslogtreecommitdiff
path: root/cmd/mdio.c
diff options
context:
space:
mode:
authorSimon Goldschmidt <simon.k.r.goldschmidt@gmail.com>2019-07-12 21:58:18 +0300
committerJoe Hershberger <joe.hershberger@ni.com>2019-07-19 00:37:13 +0300
commitcb58d18beb3cd65b66c20f913cb55c38c322457b (patch)
tree8afb0fdd3ae4c87d9cd880e1e137eff2fb8f9efd /cmd/mdio.c
parentc3d9f3f899038e21a66e1e4a685abc0a5a1d5d9c (diff)
downloadu-boot-cb58d18beb3cd65b66c20f913cb55c38c322457b.tar.xz
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 <simon.k.r.goldschmidt@gmail.com> Tested-by: Vladimir Oltean <olteanv@gmail.com> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'cmd/mdio.c')
-rw-r--r--cmd/mdio.c5
1 files changed, 5 insertions, 0 deletions
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();