[U-Boot] [PATCH] sf: prevent clean_bar overwriting error codes

Simon Glass sjg at chromium.org
Thu Dec 6 01:31:14 UTC 2018


On Tue, 27 Nov 2018 at 13:09, Simon Goldschmidt
<simon.k.r.goldschmidt at gmail.com> wrote:
>
> In spi_flash.c, if CONFIG_SPI_FLASH_BAR is enabled, the function
> 'clean_bar' makes sure that the Bank Address Register is reset at the
> end of functions using it.
>
> However, if this is enabled, those functions may return zero (success)
> when they should return an error. This is because after e.g.
> 'spi_flash_read_common' fails, the return value in 'ret' is overwritten
> with the return value of 'clean_bar'.
>
> Fix this by changing 'clean_bar' to take the outer error code into
> account and returning its own return value only if the outer error code
> is 0.
>
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>
> ---
>
>  drivers/mtd/spi/spi_flash.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list