On Thu, Jan 4, 2024 at 8:29 PM Michael Nazzareno Trimarchi <mich...@amarulasolutions.com> wrote: > > Hi > > On Thu, Jan 4, 2024 at 1:16 PM Weizhao Ouyang <o451686...@gmail.com> wrote: > > > > On Thu, Jan 4, 2024 at 8:00 PM Michal Simek <michal.si...@amd.com> wrote: > > > > > > > > > > > > On 1/4/24 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 <o451686...@gmail.com> > > > > --- > > > > 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) > > > return ret; > > > > > > don't you want to rather propagate that error? > > > > > > > Well, since the spi_flash is empty, the following code will > > print the error message and return. > > > > flash = NULL; > > if (!flash) { > printf("Failed to initialize SPI flash at %u:%u (error %d)\n", > bus, cs, ret); > return 1; > } > > This code does not change error handling that is already present here.
Hi Michael, Sorry I didn't get your point. This patch is designed to avoid spi_flash_probe_bus_cs() crash by null pointer, and let the current existing error handling to prompt it. So I'm not trying to change the current error handling. BR, Weizhao > Michael > > > BR, > > Weizhao > > > > -- > Michael Nazzareno Trimarchi > Co-Founder & Chief Executive Officer > M. +39 347 913 2170 > mich...@amarulasolutions.com > __________________________________ > > Amarula Solutions BV > Joop Geesinkweg 125, 1114 AB, Amsterdam, NL > T. +31 (0)85 111 9172 > i...@amarulasolutions.com > www.amarulasolutions.com