Skip to contentSkip to conversation

hwmon: (mp5990) Publish the OF module aliases

PATCH New hpp.iscas 2 participants 2 messages Sep 5 Hardware monitoring

lore
Share & tools
lore

hpp.iscas

author
#0 lore raw

PATCH 1/1 hwmon: (mp5990) Publish the OF module aliases

MP5990 and MP5998 Device Tree clients are matched through mp5990_of_match. Only the I2C ID table is currently published, although Device Tree clients emit OF modalias events.

Publish the existing OF table without changing PMBus operations or per-chip match data.

Fixes ce0742404ad7 ("hwmon: (pmbus) Add support for MPS Multi-phase mp5990")
---
 drivers/hwmon/pmbus/mp5990.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hwmon/pmbus/mp5990.c +1 -0
index f8a5d1b..d514395 100644
@@ -213,6 +213,7 @@ static const struct of_device_id mp5990_of_match[] = {
 	{ .compatible = "mps,mp5998", .data = (void *)mp5998 },
 	{}
 };
+MODULE_DEVICE_TABLE(of, mp5990_of_match);
 
 static struct i2c_driver mp5990_driver = {
 	.driver = {
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Unsafe fallback matching logic causes a NULL pointer dereference when probed via ACPI PRP0001. --

commit 8c03c546eec5de58e0c8478c39f38b64125e7713
Author: hpp.iscas <[email protected]>

hwmon: (mp5990) Publish the OF module aliases

MP5990 and MP5998 Device Tree clients are matched through mp5990_of_match. Only the I2C ID table is currently published, although Device Tree clients emit OF modalias events.

drivers/hwmon/pmbus/mp5990.c static const struct of_device_id mp5990_of_match[] = { · line 216

Quoted 9 lines
drivers/hwmon/pmbus/mp5990.c +1 -0
index f8a5d1b42ff7a..d5143956d4780 100644
@@ -213,6 +213,7 @@ static const struct of_device_id mp5990_of_match[] = {
 	{ .compatible = "mps,mp5998", .data = (void *)mp5998 },
 	{}
 };
+MODULE_DEVICE_TABLE(of, mp5990_of_match);

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential NULL pointer dereference in mp5990_probe():

drivers/hwmon/pmbus/mp5990.c:mp5990_probe() {
    ...
	if (client->dev.of_node)
		chip = (uintptr_t)of_device_get_match_data(&client->dev);
	else
		chip = i2c_match_id(mp5990_id, client)->driver_data;
    ...
}

If the driver is probed via an ACPI PRP0001 node, client->dev.of_node is NULL. The probe function will fall back to the else branch and call i2c_match_id().

Because the client's name is derived from ACPI (e.g., 'PRP0001:00') and is absent from mp5990_id, i2c_match_id() will return NULL.

Could the unconditional dereference of ->driver_data cause a kernel panic in this scenario?

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