The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] mfd: cros_ec: Drop OF node reference in ec_device_probe()
@ 2026-11-18  1:39 Xiangwu Lai
  2026-11-18  3:48 ` Benson Leung
  0 siblings, 1 reply; 2+ messages in thread
From: Xiangwu Lai @ 2026-11-18  1:39 UTC (permalink / raw)
  To: bleung, lee, tzungbi
  Cc: groeck, jthies, chrome-platform, mfd, linux-kernel, Xiangwu Lai

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@cmss.chinamobile.com>
---
 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




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-18  3:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18  1:39 [PATCH] mfd: cros_ec: Drop OF node reference in ec_device_probe() Xiangwu Lai
2026-11-18  3:48 ` Benson Leung

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox