[PATCH] spi: wpcm-fiu: Check the error of the SHM syscon lookup
From: Anton Protopopov
Date: Tue Dec 01 2026 - 06:22:26 EST
The syscon_regmap_lookup_by_phandle_optional() function returns NULL
only when the property is missing (-ENODEV). On other errors it
returns an error pointer. The wpcm_fiu_probe() function stores it in
fiu->shm_regmap and wpcm_fiu_stall_host() checks only for NULL. It
passes the error pointer to regmap_update_bits(), which leads to an
oops on the first operation.
The lookup may fail with a correct device tree too: it returns
-EPROBE_DEFER when the hwspinlock of the syscon or the driver which
registers its regmap is not probed yet. Return the error from the
probe, so that it is retried.
Fixes: 1f8811a2613e ("spi: wpcm-fiu: Add driver for Nuvoton WPCM450 Flash Interface Unit (FIU)")
Suggested-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
Signed-off-by: Anton Protopopov <a.s.protopopov@xxxxxxxxx>
---
It's one of three related changes, but for different trees.
See https://lore.kernel.org/linux-pci/20261127101915.1348807-1-a.s.protopopov@xxxxxxxxx/
This applies to the for-next and for-linus branches of
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
drivers/spi/spi-wpcm-fiu.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/spi/spi-wpcm-fiu.c b/drivers/spi/spi-wpcm-fiu.c
index 884e5042bad5..6dd77a8de00b 100644
--- a/drivers/spi/spi-wpcm-fiu.c
+++ b/drivers/spi/spi-wpcm-fiu.c
@@ -464,6 +464,9 @@ static int wpcm_fiu_probe(struct platform_device *pdev)
fiu->memory_size = min_t(size_t, resource_size(res), MAX_MEMORY_SIZE_TOTAL);
fiu->shm_regmap = syscon_regmap_lookup_by_phandle_optional(dev->of_node, "nuvoton,shm");
+ if (IS_ERR(fiu->shm_regmap))
+ return dev_err_probe(dev, PTR_ERR(fiu->shm_regmap),
+ "Failed to look up SHM syscon\n");
wpcm_fiu_hw_init(fiu);