[PATCH v2 2/2] leds: flash: s2m: Wire up of_match_table in platform driver
From: kr494167
Date: Wed Jul 22 2026 - 12:39:43 EST
From: Surendra <kr494167@xxxxxxxxx>
The driver defines and registers s2m_fled_of_match_table via
MODULE_DEVICE_TABLE(of, ...) but never assigns it to the platform
driver's .of_match_table field. As a result, the kernel never matches
this driver against a DT node with compatible "samsung,s2mu005-flash",
making the MODULE_DEVICE_TABLE entry dead code.
Wire the table up so that DT-based probing and module auto-loading
work as intended. In addition, validate dev->parent in s2m_fled_probe()
to prevent a NULL pointer dereference if probed without parent driver data.
Fixes: 02149db273a9 ("leds: flash: Add support for Samsung S2M series PMIC flash LED device")
Signed-off-by: Surendra <kr494167@xxxxxxxxx>
---
drivers/leds/flash/leds-s2m-flash.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/flash/leds-s2m-flash.c b/drivers/leds/flash/leds-s2m-flash.c
index 6ee8db094611..6097c75b681b 100644
--- a/drivers/leds/flash/leds-s2m-flash.c
+++ b/drivers/leds/flash/leds-s2m-flash.c
@@ -279,10 +279,17 @@ static int s2mu005_fled_init_channel(struct s2m_led *led, struct device *dev,
static int s2m_fled_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- struct sec_pmic_dev *ddata = dev_get_drvdata(dev->parent);
+ struct sec_pmic_dev *ddata;
struct s2m_led *led;
int ret;
+ if (!dev->parent)
+ return -ENODEV;
+
+ ddata = dev_get_drvdata(dev->parent);
+ if (!ddata)
+ return -ENODEV;
+
led = devm_kzalloc(dev, sizeof(*led) * MAX_CHANNELS, GFP_KERNEL);
if (!led)
return -ENOMEM;
@@ -339,6 +346,7 @@ MODULE_DEVICE_TABLE(of, s2m_fled_of_match_table);
static struct platform_driver s2m_fled_driver = {
.driver = {
.name = "s2m-flash",
+ .of_match_table = s2m_fled_of_match_table,
},
.probe = s2m_fled_probe,
.id_table = s2m_fled_id_table,
--
2.55.0