From: Stefan Ghetu <stefan.ghetu@nxp.com>
To: han.xu@nxp.com, miquel.raynal@bootlin.com
Cc: richard@nod.at, vigneshr@ti.com, s.hauer@pengutronix.de,
imx@lists.linux.dev, daniel.baluta@nxp.com,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
Stefan Ghetu <stefan.ghetu@nxp.com>
Subject: [PATCH] mtd: rawnand: gpmi: Fix possible NULL pointer dereference in gpmi_nfc_exec_op()
Date: Thu, 5 Nov 2026 12:34:10 +0200 [thread overview]
Message-ID: <20261105103410.4424-1-stefan.ghetu@nxp.com> (raw)
From: Han Xu <han.xu@nxp.com>
In gpmi_nfc_exec_op(), the desc pointer is checked inside the loop, but
that check is skipped when the loop continues in the NAND_OP_CMD_INSTR
case. As a result, desc may still be NULL when it is dereferenced after
the loop. Move the sanity check outside of the loop.
Reported by Coverity.
Fixes: ef347c0cfd61 ("mtd: rawnand: gpmi: Implement exec_op")
Signed-off-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Stefan Ghetu <stefan.ghetu@nxp.com>
---
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
index 0f1528710a6a..e876a19ee9da 100644
--- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
@@ -2616,11 +2616,11 @@ static int gpmi_nfc_exec_op(struct nand_chip *chip,
&direct);
break;
}
+ }
- if (!desc) {
- ret = -ENXIO;
- goto unmap;
- }
+ if (!desc) {
+ ret = -ENXIO;
+ goto unmap;
}
dev_dbg(this->dev, "%s setup done\n", __func__);
--
2.34.1
reply other threads:[~2026-11-05 10:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261105103410.4424-1-stefan.ghetu@nxp.com \
--to=stefan.ghetu@nxp.com \
--cc=daniel.baluta@nxp.com \
--cc=han.xu@nxp.com \
--cc=imx@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=s.hauer@pengutronix.de \
--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®