]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: sf: Fix sf probe crash
authorWeizhao Ouyang <o451686892@gmail.com>
Thu, 4 Jan 2024 11:46:19 +0000 (11:46 +0000)
committerDario Binacchi <dario.binacchi@amarulasolutions.com>
Sun, 14 Apr 2024 06:49:39 +0000 (08:49 +0200)
Handle the return value of spi_flash_probe_bus_cs() to avoid sf probe
crashes.

Link: https://lore.kernel.org/all/20240104114619.280513-1-o451686892@gmail.com
Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Acked-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
cmd/sf.c

index 730996c02b7e4cda46d1e060d1b22e83c6a2a224..e3866899f6c463df518736b3c5d10316c4df89d7 100644 (file)
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -135,8 +135,9 @@ static int do_spi_flash_probe(int argc, char *const argv[])
        }
        flash = NULL;
        if (use_dt) {
-               spi_flash_probe_bus_cs(bus, cs, &new);
-               flash = dev_get_uclass_priv(new);
+               ret = spi_flash_probe_bus_cs(bus, cs, &new);
+               if (!ret)
+                       flash = dev_get_uclass_priv(new);
        } else {
                flash = spi_flash_probe(bus, cs, speed, mode);
        }