[PATCH] mfd: cros_ec: Drop OF node reference in ec_device_probe()
From: Xiangwu Lai
Date: Tue Nov 17 2026 - 20:39:49 EST
ec_device_probe() calls of_find_compatible_node() only to check
whether a "google,cros-ec-ucsi" node exists in the device tree, but
the reference held by the returned node is never dropped.
Keep the node pointer in a local variable and release the reference
with of_node_put() right after the lookup.
Fixes: 17f95281839d ("mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI")
Signed-off-by: Xiangwu Lai <laixiangwu@xxxxxxxxxxxxxxxxxxxx>
---
drivers/mfd/cros_ec_dev.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index 529a23b80..593297df5 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -184,6 +184,7 @@ static int ec_device_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct cros_ec_platform *ec_platform = dev_get_platdata(dev);
struct cros_ec_dev *ec = kzalloc_obj(*ec);
+ struct device_node *np;
struct ec_response_pchg_count pchg_count;
int i;
@@ -269,10 +270,12 @@ static int ec_device_probe(struct platform_device *pdev)
* the required nodes. On PDC systems without FW nodes for cros_ec_ucsi,
* the driver should be added as an mfd subdevice.
*/
+ np = of_find_compatible_node(NULL, NULL, "google,cros-ec-ucsi");
+ of_node_put(np);
+
if (cros_ec_check_features(ec, EC_FEATURE_USB_PD) &&
cros_ec_check_features(ec, EC_FEATURE_UCSI_PPM) &&
- !acpi_dev_found("GOOG0021") &&
- !of_find_compatible_node(NULL, NULL, "google,cros-ec-ucsi")) {
+ !acpi_dev_found("GOOG0021") && !np) {
retval = mfd_add_hotplug_devices(ec->dev,
cros_ec_ucsi_cells,
ARRAY_SIZE(cros_ec_ucsi_cells));
--
2.50.1.windows.1