Linux LED subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/2] leds: s2m: wire up missing of_match_table in platform drivers
@ 2026-07-21  5:48 kr494167
  2026-07-21  5:48 ` [PATCH 1/2] leds: rgb: s2m: wire up of_match_table in platform driver kr494167
  2026-07-21  5:48 ` [PATCH 2/2] leds: flash: " kr494167
  0 siblings, 2 replies; 5+ messages in thread
From: kr494167 @ 2026-07-21  5:48 UTC (permalink / raw)
  To: lee, pavel; +Cc: kauschluss, linux-leds, linux-kernel, surendra

From: surendra <kr494167@gmail.com>

Both the S2M RGB and flash LED platform drivers define an OF match table
and register it with MODULE_DEVICE_TABLE(of, ...) to generate modalias
entries for DT-based module auto-loading, but forget to assign the table
to the platform_driver's .driver.of_match_table field.

The consequence is two-fold:
 - The kernel will never match and probe the driver when a DT node with
   the corresponding compatible string is present.
 - The MODULE_DEVICE_TABLE(of, ...) entries become dead code - uevent
   modalias strings are generated but the driver can never be loaded by
   them.

Both patches wire the existing tables up into the platform_driver struct,
fixing DT-based probing and module auto-loading without any functional
change to the non-DT (platform ID) probing path.

surendra (2):
  leds: rgb: s2m: wire up of_match_table in platform driver
  leds: flash: s2m: wire up of_match_table in platform driver

 drivers/leds/flash/leds-s2m-flash.c | 1 +
 drivers/leds/rgb/leds-s2m-rgb.c     | 1 +
 2 files changed, 2 insertions(+)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] leds: rgb: s2m: wire up of_match_table in platform driver
  2026-07-21  5:48 [PATCH 0/2] leds: s2m: wire up missing of_match_table in platform drivers kr494167
@ 2026-07-21  5:48 ` kr494167
  2026-07-21  5:58   ` sashiko-bot
  2026-07-21  5:48 ` [PATCH 2/2] leds: flash: " kr494167
  1 sibling, 1 reply; 5+ messages in thread
From: kr494167 @ 2026-07-21  5:48 UTC (permalink / raw)
  To: lee, pavel; +Cc: kauschluss, linux-leds, linux-kernel, surendra

From: surendra <kr494167@gmail.com>

The driver defines and registers s2m_rgb_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-rgb",
making the MODULE_DEVICE_TABLE entry dead code.

Wire the table up so that DT-based probing and module auto-loading
work as intended.

Fixes: 63ccd117f425 ("leds: rgb: Add support for Samsung S2M series PMIC RGB LED device")
Signed-off-by: surendra <kr494167@gmail.com>
---
 drivers/leds/rgb/leds-s2m-rgb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/leds/rgb/leds-s2m-rgb.c b/drivers/leds/rgb/leds-s2m-rgb.c
index d239f54eee90..28964de6920c 100644
--- a/drivers/leds/rgb/leds-s2m-rgb.c
+++ b/drivers/leds/rgb/leds-s2m-rgb.c
@@ -415,6 +415,7 @@ MODULE_DEVICE_TABLE(of, s2m_rgb_of_match_table);
 static struct platform_driver s2m_rgb_driver = {
 	.driver = {
 		.name = "s2m-rgb",
+		.of_match_table = s2m_rgb_of_match_table,
 	},
 	.probe = s2m_rgb_probe,
 	.id_table = s2m_rgb_id_table,
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] leds: flash: s2m: wire up of_match_table in platform driver
  2026-07-21  5:48 [PATCH 0/2] leds: s2m: wire up missing of_match_table in platform drivers kr494167
  2026-07-21  5:48 ` [PATCH 1/2] leds: rgb: s2m: wire up of_match_table in platform driver kr494167
@ 2026-07-21  5:48 ` kr494167
  2026-07-21  5:57   ` sashiko-bot
  1 sibling, 1 reply; 5+ messages in thread
From: kr494167 @ 2026-07-21  5:48 UTC (permalink / raw)
  To: lee, pavel; +Cc: kauschluss, linux-leds, linux-kernel, surendra

From: surendra <kr494167@gmail.com>

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.

Fixes: 02149db273a9 ("leds: flash: Add support for Samsung S2M series PMIC flash LED device")
Signed-off-by: surendra <kr494167@gmail.com>
---
 drivers/leds/flash/leds-s2m-flash.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/leds/flash/leds-s2m-flash.c b/drivers/leds/flash/leds-s2m-flash.c
index 6ee8db094611..2373a70d83eb 100644
--- a/drivers/leds/flash/leds-s2m-flash.c
+++ b/drivers/leds/flash/leds-s2m-flash.c
@@ -339,6 +339,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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] leds: flash: s2m: wire up of_match_table in platform driver
  2026-07-21  5:48 ` [PATCH 2/2] leds: flash: " kr494167
@ 2026-07-21  5:57   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-07-21  5:57 UTC (permalink / raw)
  To: kr494167; +Cc: linux-leds, lee

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Adding `.of_match_table` exposes the driver to standalone DT probing, breaking the assumption that it is strictly instantiated as an MFD cell, leading to a NULL pointer dereference or type confusion.
- [Low] The commit message violates the subsystem's capitalization guidelines for the description.
--

--- Patch [2]: [PATCH 2/2] leds: flash: s2m: wire up of_match_table in platform driver ---
commit 2a98fe49f1f26ddb2bdb4a505ce05edc54a427b5
Author: surendra <kr494167@gmail.com>

leds: flash: s2m: wire up of_match_table in platform driver

This patch wires up the s2m_fled_of_match_table to the platform driver's
of_match_table field to allow DT-based probing and module auto-loading.

> leds: flash: s2m: wire up of_match_table in platform driver

[Severity: Low]
This isn't a bug, but the LED subsystem guidelines request capitalizing the
description after the subsystem prefix. Should "wire" be "Wire"?

> diff --git a/drivers/leds/flash/leds-s2m-flash.c b/drivers/leds/flash/leds-s2m-flash.c
> index 6ee8db094611a..2373a70d83ebd 100644
> --- a/drivers/leds/flash/leds-s2m-flash.c
> +++ b/drivers/leds/flash/leds-s2m-flash.c
> @@ -339,6 +339,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,

[Severity: High]
Does adding the of_match_table expose the probe function to a NULL pointer 
dereference if probed standalone via a device tree?

Looking at s2m_fled_probe(), it assumes it is always instantiated strictly as
an MFD cell:

drivers/leds/flash/leds-s2m-flash.c:s2m_fled_probe() {
    struct sec_pmic_dev *ddata = dev_get_drvdata(dev->parent);
    ...
    ret = s2mu005_fled_init(led, dev, ddata->regmap_pmic, MAX_CHANNELS);

If this driver is bound directly via a device tree node at the root of the
device tree or under a generic bus, dev->parent won't be the MFD parent.
This means dev_get_drvdata(dev->parent) could return NULL or unrelated data,
leading to a crash when accessing ddata->regmap_pmic.

>  	},
>  	.probe = s2m_fled_probe,
>  	.id_table = s2m_fled_id_table,

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260721054846.34318-1-kr494167@gmail.com?part=2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] leds: rgb: s2m: wire up of_match_table in platform driver
  2026-07-21  5:48 ` [PATCH 1/2] leds: rgb: s2m: wire up of_match_table in platform driver kr494167
@ 2026-07-21  5:58   ` sashiko-bot
  0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-07-21  5:58 UTC (permalink / raw)
  To: kr494167; +Cc: linux-leds, lee

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Wiring up `.of_match_table` without validating `dev->parent` allows arbitrary device tree instantiation, leading to a NULL pointer dereference or type confusion.
- [Low] The commit message description after the subsystem prefix is not capitalized, violating the LED subsystem guidelines.
--

--- Patch [1]: [PATCH 1/2] leds: rgb: s2m: wire up of_match_table in platform driver ---
commit b11896849c3c9816b4973c7b324b0ca877cb4766
Author: surendra <kr494167@gmail.com>

leds: rgb: s2m: wire up of_match_table in platform driver

This commit wires up the of_match_table in the s2m-rgb platform driver.
This enables device tree based probing and module auto-loading, fixing an
issue where the MODULE_DEVICE_TABLE entry was dead code.

> leds: rgb: s2m: wire up of_match_table in platform driver

[Severity: Low]
This isn't a bug, but the commit description after the subsystem prefix
should be capitalized according to LED subsystem guidelines.

> diff --git a/drivers/leds/rgb/leds-s2m-rgb.c b/drivers/leds/rgb/leds-s2m-rgb.c
> index d239f54eee901..28964de6920ca 100644
> --- a/drivers/leds/rgb/leds-s2m-rgb.c
> +++ b/drivers/leds/rgb/leds-s2m-rgb.c
> @@ -415,6 +415,7 @@ MODULE_DEVICE_TABLE(of, s2m_rgb_of_match_table);
>  static struct platform_driver s2m_rgb_driver = {
>  	.driver = {
>  		.name = "s2m-rgb",
> +		.of_match_table = s2m_rgb_of_match_table,

[Severity: High]
Does wiring up the of_match_table here allow the driver to be probed via
an arbitrary device tree node?

If the driver is instantiated via a standalone DT node instead of through
the expected MFD parent, dev->parent might not contain the expected driver
data.

In s2m_rgb_probe(), the driver relies on the parent's drvdata:

drivers/leds/rgb/leds-s2m-rgb.c:s2m_rgb_probe() {
	...
	struct sec_pmic_dev *pmic_drvdata = dev_get_drvdata(dev->parent);
	...
	rgb->regmap = pmic_drvdata->regmap_pmic;
	...
}

Could this result in a NULL pointer dereference or type confusion if
pmic_drvdata is NULL or points to an unrelated structure?

>  	},
>  	.probe = s2m_rgb_probe,
>  	.id_table = s2m_rgb_id_table,
>  };

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260721054846.34318-1-kr494167@gmail.com?part=1

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-21  5:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21  5:48 [PATCH 0/2] leds: s2m: wire up missing of_match_table in platform drivers kr494167
2026-07-21  5:48 ` [PATCH 1/2] leds: rgb: s2m: wire up of_match_table in platform driver kr494167
2026-07-21  5:58   ` sashiko-bot
2026-07-21  5:48 ` [PATCH 2/2] leds: flash: " kr494167
2026-07-21  5:57   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox