Hi Xiangwu, Thanks for catching this OF node reference leak problem. A few comments below. On Wed, Nov 18, 2026 at 09:39:34AM +0800, Xiangwu Lai wrote: > 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 > --- > 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; > ec_device_probe() already has a "struct device_node *node;" declared immediately before this context. Please don't add another device_node pointer here just for this. Instead, scope it to the block below using "__free(device_node)". > @@ -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)); Moving the of_find_compatible_node() to before the "if" condition breaks the short-circuit evaluation, causing every ec_device_probe() call (including secondary MCUs such as FP/ISH/SCP/TP and non-UCSI Chromebooks) to walk the entire Device Tree unnecessarily looking for "google,cros-ec-ucsi". We want to only run this search if we passed the other 3 checks in the if. Also, testing "!np" after calling of_node_put(np) evaluates a pointer after its reference has already been dropped. Instead, please look into using the automatic cleanup attribute __free(device_node) added in: 9448e55d032d ("of: Add cleanup.h based auto release via __free(device_node) markings") Scope the device_node pointer inside of the block (so we keep the short circuit) and the cleanup will automatically drop the reference when leaving scope. Something like this: if (cros_ec_check_features(ec, EC_FEATURE_USB_PD) && cros_ec_check_features(ec, EC_FEATURE_UCSI_PPM) && !acpi_dev_found("GOOG0021")) { struct device_node *np __free(device_node) = of_find_compatible_node(NULL, NULL, "google,cros-ec-ucsi"); if (!np) { retval = mfd_add_hotplug_devices(ec->dev, cros_ec_ucsi_cells, ARRAY_SIZE(cros_ec_ucsi_cells)); if (retval) dev_warn(ec->dev, "failed to add cros_ec_ucsi: %d\n", retval); } } Thanks! Benson