mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/2] common: imd: handle error in imd_write_crc32
Date: Mon,  4 May 2020 10:35:42 +0200	[thread overview]
Message-ID: <20200504083542.4095-2-s.trumtrar@pengutronix.de> (raw)
In-Reply-To: <20200504083542.4095-1-s.trumtrar@pengutronix.de>

Don't just ignore the return value of write_file.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2020-05-04  8:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-04  8:35 [PATCH 1/2] scripts: bareboximd: fix write_file error handling Steffen Trumtrar
2020-05-04  8:35 ` Steffen Trumtrar [this message]
2020-05-05  5:51 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200504083542.4095-2-s.trumtrar@pengutronix.de \
    --to=s.trumtrar@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox