leds: s2m: wire up missing of_match_table in platform drivers
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
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.
--- drivers/leds/rgb/leds-s2m-rgb.c | 1 + 1 file changed, 1 insertion(+)
drivers/leds/rgb/leds-s2m-rgb.c +1 -0
@@ -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
[email protected]
AI reviewRe: [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_tablein 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@@ -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
Lee Jones
maintainerRe: [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_tablewithout validatingdev->parentallows 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_tablein platform driver --- commitb11896849c3c9816b4973c7b324b0ca877cb4766
Author: surendra <[email protected]>
Please use your full name.
Quoted 50 lines
leds: rgb: s2m: wire up
of_match_tablein platform driverThis commit wires up the
of_match_tablein the s2m-rgb platform driver. This enables device tree based probing and module auto-loading, fixing an issue where theMODULE_DEVICE_TABLEentry was dead code.Quoted 1 line
leds: rgb: s2m: wire up
of_match_tablein 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@@ -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 theof_match_tablehere 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->parentmight 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_drvdatais 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
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.
--- drivers/leds/flash/leds-s2m-flash.c | 1 + 1 file changed, 1 insertion(+)
drivers/leds/flash/leds-s2m-flash.c +1 -0
@@ -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
[email protected]
AI reviewRe: [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_tablein 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@@ -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