[PATCH 2/2] common: imd: handle error in imd_write_crc32

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

 



Don't just ignore the return value of write_file.

Signed-off-by: Steffen Trumtrar <s.trumtrar@xxxxxxxxxxxxxx>
---
 common/imd.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/common/imd.c b/common/imd.c
index 526308effa3c..5544a0131cc9 100644
--- a/common/imd.c
+++ b/common/imd.c
@@ -370,6 +370,7 @@ static int imd_write_crc32(void *buf, const struct imd_header *imd_start,
 		return -ENODATA;
 	} else {
 		uint32_t *p = (uint32_t *)(imd_crc + 1);
+		int ret;
 
 		if (*p != crc) {
 			uint32_t *flags = imd_crc32_flags(imd_crc);
@@ -377,7 +378,11 @@ static int imd_write_crc32(void *buf, const struct imd_header *imd_start,
 			debug("Update crc token from 0x%08x to 0x%08x (flags 0x%08x)\n", *p, crc, *flags);
 			*p = crc;
 
-			write_file(filename, buf, size);
+			ret = write_file(filename, buf, size);
+			if (ret < 0) {
+				eprintf("CRC: write crc token to %s failed: %d\n", filename, ret);
+				return ret;
+			}
 		}
 	}
 
-- 
2.26.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