[PATCH 08/15] ARM: i.MX bbu-external-nand: Do not modify image

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



struct bbu_data::image is const, so do not modify the image, but create
a copy instead.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 arch/arm/mach-imx/imx-bbu-external-nand.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/imx-bbu-external-nand.c b/arch/arm/mach-imx/imx-bbu-external-nand.c
index 8aa4f152a1..0f7cc51caf 100644
--- a/arch/arm/mach-imx/imx-bbu-external-nand.c
+++ b/arch/arm/mach-imx/imx-bbu-external-nand.c
@@ -39,7 +39,7 @@ static int imx_bbu_external_nand_update(struct bbu_handler *handler, struct bbu_
 	uint32_t num_bb = 0, bbt = 0;
 	loff_t offset = 0;
 	int block = 0, len, now, blocksize;
-	void *image = data->image;
+	void *image = NULL;
 
 	ret = stat(data->devicefile, &s);
 	if (ret)
@@ -55,6 +55,12 @@ static int imx_bbu_external_nand_update(struct bbu_handler *handler, struct bbu_
 	if (ret)
 		goto out;
 
+	image = memdup(data->image, data->len);
+	if (!image) {
+		ret = -ENOMEM;
+		goto out;
+	}
+
 	blocksize = meminfo.erasesize;
 
 	size_need = data->len;
@@ -172,6 +178,7 @@ static int imx_bbu_external_nand_update(struct bbu_handler *handler, struct bbu_
 
 out:
 	close(fd);
+	free(image);
 
 	return ret;
 }
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux