mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-09-28 17:21:36 +02:00
spi: sf_ops: Check the return value from spi_flash_cmd_read_status()
We should check the return value from spi_flash_cmd_read_status() and propagate it in the case of error. This fixes a defect caught by Coverity. Reported-by: Tom Rini <trini@konsulko.com> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Reviewed-by: Jagan Teki <jteki@openedev.com>
This commit is contained in:
parent
5168721e58
commit
a668a164ff
@ -663,8 +663,11 @@ int stm_lock(struct spi_flash *flash, u32 ofs, size_t len)
|
|||||||
u8 status_old, status_new;
|
u8 status_old, status_new;
|
||||||
u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
|
u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
|
||||||
u8 shift = ffs(mask) - 1, pow, val;
|
u8 shift = ffs(mask) - 1, pow, val;
|
||||||
|
int ret;
|
||||||
|
|
||||||
spi_flash_cmd_read_status(flash, &status_old);
|
ret = spi_flash_cmd_read_status(flash, &status_old);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
/* SPI NOR always locks to the end */
|
/* SPI NOR always locks to the end */
|
||||||
if (ofs + len != flash->size) {
|
if (ofs + len != flash->size) {
|
||||||
@ -714,8 +717,11 @@ int stm_unlock(struct spi_flash *flash, u32 ofs, size_t len)
|
|||||||
uint8_t status_old, status_new;
|
uint8_t status_old, status_new;
|
||||||
u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
|
u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
|
||||||
u8 shift = ffs(mask) - 1, pow, val;
|
u8 shift = ffs(mask) - 1, pow, val;
|
||||||
|
int ret;
|
||||||
|
|
||||||
spi_flash_cmd_read_status(flash, &status_old);
|
ret = spi_flash_cmd_read_status(flash, &status_old);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
/* Cannot unlock; would unlock larger region than requested */
|
/* Cannot unlock; would unlock larger region than requested */
|
||||||
if (stm_is_locked_sr(flash, status_old, ofs - flash->erase_size,
|
if (stm_is_locked_sr(flash, status_old, ofs - flash->erase_size,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user