From: James Hilliard <james.hilliard1@gmail.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Manivannan Sadhasivam <mani@kernel.org>,
Christian Marangi <ansuelsmth@gmail.com>,
Sricharan R <quic_srichara@quicinc.com>,
Md Sadre Alam <quic_mdalam@quicinc.com>,
Boris Brezillon <bbrezillon@kernel.org>
Cc: linux-mtd@lists.infradead.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org,
James Hilliard <james.hilliard1@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH v2 2/4] mtd: rawnand: qcom: retain the BAM transaction if replacement fails
Date: Sun, 08 Nov 2026 15:42:09 -0700 [thread overview]
Message-ID: <20261108-submit-qcom-nand-child-probe-errors-v1-v2-2-4a8704cbf7b4@gmail.com> (raw)
In-Reply-To: <20261108-submit-qcom-nand-child-probe-errors-v1-v2-0-4a8704cbf7b4@gmail.com>
Attaching a chip frees the controller's BAM transaction before allocating
one sized for its page geometry. Allocation failure leaves bam_txn NULL,
although later chip scans and previously registered chips still use that
shared transaction.
Allocate the replacement before freeing the old transaction. Restore the
old capacity on failure so the controller retains a usable transaction
for already initialized chips, including I/O during probe cleanup.
Fixes: ba7542eb2dd5 ("mtd: rawnand: qcom: fix memory corruption that causes panic")
Cc: stable@vger.kernel.org
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/mtd/nand/raw/qcom_nandc.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index f240d1effa04..062fba9eaecc 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -1329,21 +1329,22 @@ static int qcom_nand_attach_chip(struct nand_chip *chip)
ecc->engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
mtd_set_ooblayout(mtd, &qcom_nand_ooblayout_ops);
- /* Free the initially allocated BAM transaction for reading the ONFI params */
- if (nandc->props->supports_bam)
- qcom_free_bam_transaction(nandc);
-
- nandc->max_cwperpage = max_t(unsigned int, nandc->max_cwperpage,
- cwperpage);
-
/* Now allocate the BAM transaction based on updated max_cwperpage */
if (nandc->props->supports_bam) {
- nandc->bam_txn = qcom_alloc_bam_transaction(nandc);
- if (!nandc->bam_txn) {
+ unsigned int old_max_cwperpage = nandc->max_cwperpage;
+ struct bam_transaction *bam_txn;
+
+ nandc->max_cwperpage = max_t(unsigned int, old_max_cwperpage,
+ cwperpage);
+ bam_txn = qcom_alloc_bam_transaction(nandc);
+ if (!bam_txn) {
+ nandc->max_cwperpage = old_max_cwperpage;
dev_err(nandc->dev,
"failed to allocate bam transaction\n");
return -ENOMEM;
}
+ qcom_free_bam_transaction(nandc);
+ nandc->bam_txn = bam_txn;
}
/*
--
2.53.0
next prev parent reply other threads:[~2026-11-08 22:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 22:42 [PATCH v2 0/4] mtd: rawnand: qcom: unwind failed child initialization James Hilliard
2026-11-08 22:42 ` [PATCH v2 1/4] mtd: rawnand: qcom: parse boot partitions before registering MTD James Hilliard
2026-11-08 22:42 ` James Hilliard [this message]
2026-11-08 22:42 ` [PATCH v2 3/4] mtd: rawnand: qcom: unwind registered chips on child probe failure James Hilliard
2026-11-08 22:42 ` [PATCH v2 4/4] mtd: rawnand: qcom: scan all chips before registering MTD devices James Hilliard
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=20261108-submit-qcom-nand-child-probe-errors-v1-v2-2-4a8704cbf7b4@gmail.com \
--to=james.hilliard1@gmail.com \
--cc=ansuelsmth@gmail.com \
--cc=bbrezillon@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=mani@kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=quic_mdalam@quicinc.com \
--cc=quic_srichara@quicinc.com \
--cc=richard@nod.at \
--cc=stable@vger.kernel.org \
--cc=vigneshr@ti.com \
/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
all inboxes | Powered by JetHome®