From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 14 Oct 2022 18:42:24 +0200 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ojNlR-008iH6-0L for lore@lore.pengutronix.de; Fri, 14 Oct 2022 18:42:24 +0200 Received: from localhost ([127.0.0.1] helo=metis.ext.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1ojNlE-0006TO-PA; Fri, 14 Oct 2022 18:42:12 +0200 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ojNlB-0006GF-MZ; Fri, 14 Oct 2022 18:42:09 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1ojNlB-001WU4-1K; Fri, 14 Oct 2022 18:42:09 +0200 Received: from mfe by dude02.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1ojNl8-00FzpI-L7; Fri, 14 Oct 2022 18:42:06 +0200 From: Marco Felsch To: oss-tools@pengutronix.de Date: Fri, 14 Oct 2022 18:41:52 +0200 Message-Id: <20221014164204.3812506-3-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221014164204.3812506-1-m.felsch@pengutronix.de> References: <20221014164204.3812506-1-m.felsch@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [OSS-Tools] [PATCH dt-utils 02/14] state: backend_raw: fix ignoring unpack failures X-BeenThere: oss-tools@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: Pengutronix Public Open-Source-Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mfe@pengutronix.de Sender: "OSS-Tools" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: oss-tools-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false This ports the following barebox commit | commit 9866966ef9b38bf49276c67f7e258bc2a8df55eb | Author: Marco Felsch | Date: Wed Aug 25 16:49:04 2021 +0200 | | state: backend_raw: fix ignoring unpack failures | | This is required to inform the state framework that the state variable | set have changed and we need to write the new variable set. Without this | fix the new variable set is never written since the state never sets | dirty=1 and so state_save() will return early without saving the new | variable set. | | Signed-off-by: Marco Felsch | Link: https://lore.barebox.org/20210825144904.4929-1-m.felsch@pengutronix.de | Signed-off-by: Sascha Hauer Signed-off-by: Marco Felsch --- src/barebox-state/backend_format_raw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/barebox-state/backend_format_raw.c b/src/barebox-state/backend_format_raw.c index 9fade5d..982df12 100644 --- a/src/barebox-state/backend_format_raw.c +++ b/src/barebox-state/backend_format_raw.c @@ -181,6 +181,7 @@ static int backend_format_raw_unpack(struct state_backend_format *format, const struct backend_raw_header *header; const void *data; struct state_backend_format_raw *backend_raw = get_format_raw(format); + int ret = 0; header = (const struct backend_raw_header *)buf; data = buf + sizeof(*header); @@ -189,12 +190,13 @@ static int backend_format_raw_unpack(struct state_backend_format *format, if (sv->start + sv->size > header->data_len) { dev_err(backend_raw->dev, "State variable ends behind valid data, %s\n", sv->name); + ret = -ENOSPC; continue; } memcpy(sv->raw, data + sv->start, sv->size); } - return 0; + return ret; } static int backend_format_raw_pack(struct state_backend_format *format, -- 2.30.2