[PATCH] mtd: spinand: fix NULL pointer dereference in spinand_support_vendor_ops()

Md Sadre Alam posted 1 patch 2 days, 6 hours ago
drivers/mtd/nand/spi/core.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] mtd: spinand: fix NULL pointer dereference in spinand_support_vendor_ops()
Posted by Md Sadre Alam 2 days, 6 hours ago
The spinand_support_vendor_ops() helper unconditionally dereferences
info->vendor_ops. For chips that do not define vendor_ops, this pointer
is NULL, leading to a kernel panic during probe:

Unable to handle kernel NULL pointer dereference at virtual address
0000000000000008

Add a guard to return early when vendor_ops is NULL. This prevents the
crash and allows SPI NAND devices without vendor-specific operations to
be probed correctly.

Fixes: fbc7538782f8 ("mtd: spinand: List vendor specific operations and make sure they are supported")
Cc: stable@vger.kernel.org
Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
---
 drivers/mtd/nand/spi/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 514f653f27f3..29fb2ac19569 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -1435,6 +1435,8 @@ static int spinand_support_vendor_ops(struct spinand_device *spinand,
 {
 	int i;
 
+	if (!info->vendor_ops)
+		return 0;
 	/*
 	 * The vendor ops array is only used in order to verify this chip and all its memory
 	 * operations are supported. If we see patterns emerging, we could ideally name these
-- 
2.34.1
Re: [PATCH] mtd: spinand: fix NULL pointer dereference in spinand_support_vendor_ops()
Posted by Miquel Raynal 2 days, 1 hour ago
On Fri, 06 Feb 2026 14:07:52 +0530, Md Sadre Alam wrote:
> The spinand_support_vendor_ops() helper unconditionally dereferences
> info->vendor_ops. For chips that do not define vendor_ops, this pointer
> is NULL, leading to a kernel panic during probe:
> 
> Unable to handle kernel NULL pointer dereference at virtual address
> 0000000000000008
> 
> [...]

Applied to nand/next, thanks!

[1/1] mtd: spinand: fix NULL pointer dereference in spinand_support_vendor_ops()
      commit: e82269e7cb93a2d33368418be4ee56015b4adc27

Patche(s) should be available on mtd/linux.git and will be
part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl