]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: mdio: prevent data abort when no mdio bus is found
authorSimon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Fri, 12 Jul 2019 18:58:18 +0000 (20:58 +0200)
committerJoe Hershberger <joe.hershberger@ni.com>
Thu, 18 Jul 2019 21:37:13 +0000 (16:37 -0500)
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>
cmd/mdio.c

index a6fa9266d0c46ce1620324e519d007dc7d935151..add6440813f6f4f759c0d966eb0c8e78d7f818c7 100644 (file)
@@ -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();