Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

spi: wpcm-fiu: Fix potential NULL pointer dereference in wpcm_fiu_probe()

platform_get_resource_byname() can return NULL, which would cause a crash
when passed the pointer to resource_size().

Move the fiu->memory_size assignment after the error check for
devm_ioremap_resource() to prevent the potential NULL pointer dereference.

Fixes: 9838c182471e ("spi: wpcm-fiu: Add direct map support")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Reviewed-by: J. Neuschäfer <j.ne@posteo.net>
Link: https://patch.msgid.link/20260212-wpcm-v1-1-5b7c4f526aac@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Felix Gu and committed by
Mark Brown
888a0a80 5af56f30

+1 -1
+1 -1
drivers/spi/spi-wpcm-fiu.c
··· 459 459 460 460 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "memory"); 461 461 fiu->memory = devm_ioremap_resource(dev, res); 462 - fiu->memory_size = min_t(size_t, resource_size(res), MAX_MEMORY_SIZE_TOTAL); 463 462 if (IS_ERR(fiu->memory)) 464 463 return dev_err_probe(dev, PTR_ERR(fiu->memory), 465 464 "Failed to map flash memory window\n"); 466 465 466 + fiu->memory_size = min_t(size_t, resource_size(res), MAX_MEMORY_SIZE_TOTAL); 467 467 fiu->shm_regmap = syscon_regmap_lookup_by_phandle_optional(dev->of_node, "nuvoton,shm"); 468 468 469 469 wpcm_fiu_hw_init(fiu);