]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
common: mii: Do not allow to exceed max phy limit
authorMichal Simek <michal.simek@xilinx.com>
Mon, 19 Oct 2015 13:13:34 +0000 (15:13 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 19 Nov 2015 13:03:05 +0000 (14:03 +0100)
Phy can have addresses 0-31. Check this boundary to ensure that user
can't call commands on phy address 32 and more.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
common/cmd_mii.c

index 5e9079da048784c1b01897c9e42f2e14a1a73232..7ef7532a502a01c955339f28269dc3fcee342c59 100644 (file)
@@ -314,6 +314,11 @@ static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        mask = simple_strtoul(argv[5], NULL, 16);
        }
 
+       if (addrhi > 31) {
+               printf("Incorrect PHY address. Range should be 0-31\n");
+               return CMD_RET_USAGE;
+       }
+
        /* use current device */
        devname = miiphy_get_current_dev();