common/cmd_mii.c: Add sanity argc check
authorShinya Kuribayashi <shinya.kuribayashi@necel.com>
Thu, 27 Dec 2007 06:39:54 +0000 (15:39 +0900)
committerWolfgang Denk <wd@denx.de>
Wed, 9 Jan 2008 20:36:29 +0000 (21:36 +0100)
If type mii command without arguments, we suffer from uninitialized argv[]
entries; for example we MIPS get stuck by TLB error.

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi@necel.com>
common/cmd_mii.c

index f530a38421e04b61169ee60e6804a027fa2a213b..079612a4e65644659a7e7899ad56265b05a1b32c 100644 (file)
@@ -438,6 +438,11 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
        int             rcode = 0;
        char            *devname;
 
+       if (argc < 2) {
+               printf("Usage:\n%s\n", cmdtp->usage);
+               return 1;
+       }
+
 #if defined(CONFIG_8xx) || defined(CONFIG_MCF532x)
        mii_init ();
 #endif