From: Marek BehĂșn <marek.behun@nic.cz>
Date: Tue, 5 Oct 2021 13:55:57 +0000 (+0200)
Subject: mtd: spi-nor-core: Try cleaning up in case writing BAR failed
X-Git-Tag: v2025.01-rc5-pxa1908~1669^2~13
X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=36384f612da992ab485c4b7cd768a89e8c3fe8cf;p=u-boot.git

mtd: spi-nor-core: Try cleaning up in case writing BAR failed

Use the cleanup codepath of spi_nor_erase() also in the event of failure
of writing the BAR register.

Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Tested-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
---

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 7572be5e34..6da7dc3a25 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -929,7 +929,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
 #ifdef CONFIG_SPI_FLASH_BAR
 		ret = write_bar(nor, addr);
 		if (ret < 0)
-			return ret;
+			goto erase_err;
 #endif
 		write_enable(nor);