Skip to content

Commit 660b412

Browse files
authored
HSD# 16027100077-3: mtd: spi-nor: core: Check for null pointer to avoid soft error
Ensure that the pointer passed to module_put() in spi_nor_put_device() is not NULL before use. In certain configurations, the pointer may be uninitialized or NULL, which can lead to a null pointer dereference and a soft kernel error. This change adds a guard clause to return early, preventing the error and maintaining system stability without requiring a reboot. Signed-off-by: Khairul Anuar Romli <[email protected]>
1 parent 9804ccc commit 660b412

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/mtd/spi-nor/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3250,7 +3250,8 @@ static void spi_nor_put_device(struct mtd_info *mtd)
32503250
else
32513251
dev = nor->dev;
32523252

3253-
module_put(dev->driver->owner);
3253+
if (dev && dev->driver && dev->driver->owner)
3254+
module_put(dev->driver->owner);
32543255
}
32553256

32563257
static void spi_nor_restore(struct spi_nor *nor)

0 commit comments

Comments
 (0)