mtd: uboot: Fix hanging during mtd list command
[oweals/u-boot.git] / drivers / mtd / mtd_uboot.c
index 6a211d52ff8511a71f0a52d90b7ebdc735b368e6..7d7a11c990d6a0b75822fe42d1a5d5307e3b4321 100644 (file)
@@ -104,7 +104,10 @@ int mtd_probe_devices(void)
        mtd_probe_uclass_mtd_devs();
 
        /* Check if mtdparts/mtdids changed since last call, otherwise: exit */
-       if (!strcmp(mtdparts, old_mtdparts) && !strcmp(mtdids, old_mtdids))
+       if ((!mtdparts && !old_mtdparts && !mtdids && !old_mtdids) ||
+           (mtdparts && old_mtdparts && mtdids && old_mtdids &&
+            !strcmp(mtdparts, old_mtdparts) &&
+            !strcmp(mtdids, old_mtdids)))
                return 0;
 
        /* Update the local copy of mtdparts */
@@ -140,6 +143,10 @@ int mtd_probe_devices(void)
                }
        }
 
+       /* If either mtdparts or mtdids is empty, then exit */
+       if (!mtdparts || !mtdids)
+               return 0;
+
        /* Start the parsing by ignoring the extra 'mtdparts=' prefix, if any */
        if (strstr(mtdparts, "mtdparts="))
                mtdparts += 9;