summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@freescale.com>2015-11-17 17:13:33 -0200
committerJagan Teki <jteki@openedev.com>2015-11-18 00:55:29 +0530
commita668a164ffb73db6f566f50e9440c872d5293742 (patch)
tree7673473c7c76d8504338d667222c07a412117195 /drivers
parent5168721e584e1fc104ccc3b1a027e8973a18f65b (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/spi/sf_ops.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c
index 4065520726..3a56d7f55c 100644
--- a/drivers/mtd/spi/sf_ops.c
+++ b/drivers/mtd/spi/sf_ops.c
@@ -663,8 +663,11 @@ int stm_lock(struct spi_flash *flash, u32 ofs, size_t len)
u8 status_old, status_new;
u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
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 */
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;
u8 mask = SR_BP2 | SR_BP1 | SR_BP0;
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 */
if (stm_is_locked_sr(flash, status_old, ofs - flash->erase_size,