Commit e82269e7 authored by Md Sadre Alam's avatar Md Sadre Alam Committed by Miquel Raynal
Browse files

mtd: spinand: fix NULL pointer dereference in spinand_support_vendor_ops()



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: fbc75387 ("mtd: spinand: List vendor specific operations and make sure they are supported")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarMd Sadre Alam <quic_mdalam@quicinc.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent 1e06dbfd
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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