diff mbox series

[RESEND,u-boot-spi,2/8] mtd: spi-nor-core: Check return value of write_enable() in spi_nor_erase()

Message ID 20210714235109.25228-3-marek.behun@nic.cz
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series Fix `mtd erase` when used with mtdpart | expand

Commit Message

Marek Behún July 14, 2021, 11:51 p.m. UTC
The spi_nor_erase() function does not check return value of the
write_enable() call. Fix this.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Tested-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
---
 drivers/mtd/spi/spi-nor-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Simon Glass July 20, 2021, 6:32 p.m. UTC | #1
On Wed, 14 Jul 2021 at 17:51, Marek Behún <marek.behun@nic.cz> wrote:
>
> The spi_nor_erase() function does not check return value of the
> write_enable() call. Fix this.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> Tested-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
> ---
>  drivers/mtd/spi/spi-nor-core.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
Jagan Teki July 21, 2021, 3:50 p.m. UTC | #2
On Thu, Jul 15, 2021 at 5:21 AM Marek Behún <marek.behun@nic.cz> wrote:
>
> The spi_nor_erase() function does not check return value of the
> write_enable() call. Fix this.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> Tested-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
> ---

Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
diff mbox series

Patch

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 7ce8dc5502..8fd1d684f2 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -929,7 +929,9 @@  static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
 		if (ret < 0)
 			goto erase_err;
 #endif
-		write_enable(nor);
+		ret = write_enable(nor);
+		if (ret < 0)
+			goto erase_err;
 
 		ret = spi_nor_erase_sector(nor, addr);
 		if (ret < 0)