Skip to content

Commit e82269e

Browse files
Md Sadre Alammiquelraynal
authored andcommitted
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: fbc7538 ("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> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent 1e06dbf commit e82269e

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/mtd/nand/spi/core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,8 @@ static int spinand_support_vendor_ops(struct spinand_device *spinand,
14351435
{
14361436
int i;
14371437

1438+
if (!info->vendor_ops)
1439+
return 0;
14381440
/*
14391441
* The vendor ops array is only used in order to verify this chip and all its memory
14401442
* operations are supported. If we see patterns emerging, we could ideally name these

0 commit comments

Comments
 (0)