Skip to contentSkip to conversation

leds: s2m: wire up missing of_match_table in platform drivers

PATCH Superseded [email protected] 3 participants 6 messages Jul 21 – Jul 22 LED

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover leds: s2m: wire up missing of_match_table in platform drivers

From: surendra <[email protected]>

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(+)
Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/2 leds: rgb: s2m: wire up of_match_table in platform driver

From: surendra <[email protected]>

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")
---
 drivers/leds/rgb/leds-s2m-rgb.c | 1 +
 1 file changed, 1 insertion(+)
drivers/leds/rgb/leds-s2m-rgb.c +1 -0
index d239f54eee90..28964de6920c 100644
@@ -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,
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH 1/2] leds: rgb: s2m: wire up of_match_table in platform driver

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…

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 <[email protected]>

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.

Quoted 1 line

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.

drivers/leds/rgb/leds-s2m-rgb.c MODULE_DEVICE_TABLE(of, s2m_rgb_of_match_table); · line 418

Quoted 9 lines
drivers/leds/rgb/leds-s2m-rgb.c +1 -0
index d239f54eee901..28964de6920ca 100644
@@ -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?

Quoted 4 lines
drivers/leds/rgb/leds-s2m-rgb.c +0 -0
 	},
 	.probe = s2m_rgb_probe,
 	.id_table = s2m_rgb_id_table,

};

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#3 lore raw

Re: [PATCH 1/2] leds: rgb: s2m: wire up of_match_table in platform driver

Quoted 8 lines · On Tue, 21 Jul 2026, [email protected] wrote:

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 <[email protected]>

Please use your full name.

Quoted 50 lines

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.

Quoted 1 line

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.

drivers/leds/rgb/leds-s2m-rgb.c MODULE_DEVICE_TABLE(of, s2m_rgb_of_match_table); · line 418

Quoted 9 lines
drivers/leds/rgb/leds-s2m-rgb.c +1 -0
index d239f54eee901..28964de6920ca 100644
@@ -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?

Quoted 4 lines
drivers/leds/rgb/leds-s2m-rgb.c +0 -0
 	},
 	.probe = s2m_rgb_probe,
 	.id_table = s2m_rgb_id_table,

};

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Signature · 1 line
Lee Jones
#4 lore raw

PATCH 2/2 leds: flash: s2m: wire up of_match_table in platform driver

In reply to [email protected]

From: surendra <[email protected]>

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")
---
 drivers/leds/flash/leds-s2m-flash.c | 1 +
 1 file changed, 1 insertion(+)
drivers/leds/flash/leds-s2m-flash.c +1 -0
index 6ee8db094611..2373a70d83eb 100644
@@ -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,
Signature · 1 line
2.55.0
#5 lore raw

Re: [PATCH 2/2] leds: flash: s2m: wire up of_match_table in platform driver

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…

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 <[email protected]>

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.

Quoted 1 line

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"?

drivers/leds/flash/leds-s2m-flash.c MODULE_DEVICE_TABLE(of, s2m_fled_of_match_table); · line 342

Quoted 9 lines
drivers/leds/flash/leds-s2m-flash.c +1 -0
index 6ee8db094611a..2373a70d83ebd 100644
@@ -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.

Quoted 3 lines
drivers/leds/flash/leds-s2m-flash.c +0 -0
 	},
 	.probe = s2m_fled_probe,
 	.id_table = s2m_fled_id_table,
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2