[PATCH] cmd: sf: Fix sf probe crash
Dario Binacchi
dario.binacchi at amarulasolutions.com
Sun Apr 14 15:45:22 CEST 2024
Hi Weizhao,
On Fri, Mar 15, 2024 at 7:07 PM Jonas Karlman <jonas at kwiboo.se> wrote:
>
> Hi,
>
> On 2024-01-04 12:46, Weizhao Ouyang wrote:
> > Handle the return value of spi_flash_probe_bus_cs() to avoid sf probe
> > crashes.
> >
> > Signed-off-by: Weizhao Ouyang <o451686892 at gmail.com>
>
> This fixes a null pointer dereference when running "sf probe" and there
> are no spi devices enabled in the device tree for my boards, so:
>
> Fixes: 3feea0ba196a ("spi: spi_flash_probe_bus_cs() rely on DT for spi speed and mode")
>
> Reviewed-by: Jonas Karlman <jonas at kwiboo.se>
>
> Regards,
> Jonas
>
> > ---
> > cmd/sf.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/cmd/sf.c b/cmd/sf.c
> > index 730996c02b..e3866899f6 100644
> > --- 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);
> > }
>
Applied to nand-next
Thanks and regards
Dario
--
Dario Binacchi
Senior Embedded Linux Developer
dario.binacchi at amarulasolutions.com
__________________________________
Amarula Solutions SRL
Via Le Canevare 30, 31100 Treviso, Veneto, IT
T. +39 042 243 5310
info at amarulasolutions.com
www.amarulasolutions.com
More information about the U-Boot
mailing list