From: sashiko-bot@kernel.org
To: "Sagnik Sasmal" <sagnik@sagnik.me>, miquel.raynal@bootlin.com
Cc: vigneshr@ti.com, richard@nod.at, linux-mtd@lists.infradead.org,
mikhail.kshevetskiy@iopsys.eu, linux-kernel@vger.kernel.org,
tudor.ambarus@linaro.org
Subject: Re: [PATCH v2] mtd: spinand: Do not update the QE bit on devices without one
Date: Thu, 10 Sep 2026 16:54:14 +0000 [thread overview]
Message-ID: <20260910165414.A7BCD1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <010701a08c36e962-eb595dbe-b80b-44eb-858d-c1033f8a86a1-000000@eu-central-1.amazonses.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Uninitialized return value in `spinand_configure_chip()` can cause device probe failure.
--
commit 25afeaf20864d4f79fe9a314c125190119930965
Author: Sagnik Sasmal <sagnik@sagnik.me>
mtd: spinand: Do not update the QE bit on devices without one
This patch moves the call to spinand_init_quad_enable() inside the
SPINAND_HAS_QE_BIT condition to avoid clearing configuration register bit 0
on devices without a QE bit.
> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
> index 43bbe2629b85b..e59581d3596b7 100644
> --- a/drivers/mtd/nand/spi/core.c
> +++ b/drivers/mtd/nand/spi/core.c
> @@ -1813,11 +1813,11 @@ static int spinand_configure_chip(struct spinand_device *spinand)
> spinand->ssdr_op_templates.write_cache->data.buswidth == 4 ||
> spinand->ssdr_op_templates.update_cache->data.buswidth == 4)
> quad_enable = true;
> - }
>
> - ret = spinand_init_quad_enable(spinand, quad_enable);
> - if (ret)
> - return ret;
> + ret = spinand_init_quad_enable(spinand, quad_enable);
> + if (ret)
> + return ret;
> + }
>
> if (spinand->configure_chip) {
> ret = spinand->configure_chip(spinand, SSDR);
[Severity: High]
Does this code leave 'ret' uninitialized if the device lacks both the
SPINAND_HAS_QE_BIT flag and a configure_chip callback?
Looking at the rest of spinand_configure_chip() in drivers/mtd/nand/spi/core.c:
static int spinand_configure_chip(struct spinand_device *spinand)
{
bool odtr = false, quad_enable = false;
int ret;
...
try_ssdr:
if (spinand->flags & SPINAND_HAS_QE_BIT) {
...
ret = spinand_init_quad_enable(spinand, quad_enable);
if (ret)
return ret;
}
if (spinand->configure_chip) {
ret = spinand->configure_chip(spinand, SSDR);
if (ret)
return ret;
}
return ret;
}
If neither condition is met, it appears the function will return an
uninitialized stack variable. If this stack memory holds a non-zero value,
the caller spinand_init_flash() may treat it as a failure and abort device
initialization.
--
Sashiko AI review · https://sashiko.dev/#/patchset/010701a08c36e962-eb595dbe-b80b-44eb-858d-c1033f8a86a1-000000@eu-central-1.amazonses.com?part=1
next prev parent reply other threads:[~2026-09-10 16:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 11:33 [PATCH] " Sagnik Sasmal
2026-09-10 12:40 ` Miquel Raynal
2026-09-10 16:46 ` [PATCH v2] " Sagnik Sasmal
2026-09-10 16:54 ` sashiko-bot [this message]
2026-09-10 22:44 ` [PATCH v3] " Sagnik Sasmal
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=20260910165414.A7BCD1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=mikhail.kshevetskiy@iopsys.eu \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=sagnik@sagnik.me \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tudor.ambarus@linaro.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®