From: James Hilliard <james.hilliard1@gmail.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Richard Genoud <richard.genoud@bootlin.com>
Cc: linux-mtd@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org,
James Hilliard <james.hilliard1@gmail.com>
Subject: [PATCH 1/3] mtd: rawnand: sunxi: propagate user-data allocation errors
Date: Tue, 11 Aug 2026 00:01:59 -0600 [thread overview]
Message-ID: <20260811-sunxi-nand-protected-oob-fixes-v1-1-412e50444673@gmail.com> (raw)
In-Reply-To: <20260811-sunxi-nand-protected-oob-fixes-v1-0-412e50444673@gmail.com>
sunxi_nfc_maximize_user_data() returns -ENOMEM when its per-step
length array cannot be allocated, but the caller ignores that error.
The NULL array then makes sunxi_nfc_user_data_sz() report the fixed
four-byte fallback, which is not the layout that the variable-length
setup calculated.
Return the setup error so an allocation failure cannot silently select
and validate a different OOB layout.
Fixes: 54dcd6aa69db ("mtd: rawnand: sunxi: introduce maximize variable user data length")
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/mtd/nand/raw/sunxi_nand.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
index 45ccbce91551..108161fe10cb 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.c
+++ b/drivers/mtd/nand/raw/sunxi_nand.c
@@ -2072,6 +2072,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,
int total_user_data_sz = 0;
int nsectors;
int ecc_mode;
+ int ret;
int i;
if (nanddev->ecc.user_conf.flags & NAND_ECC_MAXIMIZE_STRENGTH) {
@@ -2169,9 +2170,12 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,
* The rationale for variable data length is to prioritize maximum ECC
* strength, and then use the remaining space for user data.
*/
- if (nfc->caps->reg_user_data_len)
- sunxi_nfc_maximize_user_data(nand, mtd->oobsize, ecc->bytes,
- nsectors);
+ if (nfc->caps->reg_user_data_len) {
+ ret = sunxi_nfc_maximize_user_data(nand, mtd->oobsize,
+ ecc->bytes, nsectors);
+ if (ret)
+ return ret;
+ }
if (total_user_data_sz == 0)
for (i = 0; i < nsectors; i++)
--
2.53.0
next prev parent reply other threads:[~2026-08-11 6:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 6:01 [PATCH 0/3] mtd: rawnand: sunxi: harden protected OOB handling James Hilliard
2026-08-11 6:01 ` James Hilliard [this message]
2026-08-11 6:02 ` [PATCH 2/3] mtd: rawnand: sunxi: reserve a full user-data word for BBM James Hilliard
2026-08-11 6:02 ` [PATCH 3/3] mtd: rawnand: sunxi: use a stack buffer for BBM randomization James Hilliard
2026-09-04 18:08 ` [PATCH 0/3] mtd: rawnand: sunxi: harden protected OOB handling Miquel Raynal
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=20260811-sunxi-nand-protected-oob-fixes-v1-1-412e50444673@gmail.com \
--to=james.hilliard1@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=miquel.raynal@bootlin.com \
--cc=richard.genoud@bootlin.com \
--cc=richard@nod.at \
--cc=samuel@sholland.org \
--cc=vigneshr@ti.com \
--cc=wens@kernel.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