Re: [PATCH v3] mfd: cros_ec: Drop OF node reference in ec_device_probe()

From: Tzung-Bi Shih

Date: Sun Nov 22 2026 - 22:04:24 EST


On Mon, Nov 23, 2026 at 10:50:22AM +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.
>
> Scope the lookup to the UCSI block and mark the node pointer with
> __free(device_node), so that the reference is released automatically
> when the block is left. Keeping the lookup inside the block also
> preserves the short-circuit evaluation of the original condition:
> the device tree is only walked when the EC_FEATURE_USB_PD,
> EC_FEATURE_UCSI_PPM and ACPI checks already passed, instead of on
> every probe of every cros_ec device.
>
> Fixes: 17f95281839d ("mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI")
> Suggested-by: Benson Leung <bleung@xxxxxxxxxxxx>
> Reviewed-by: Benson Leung <bleung@xxxxxxxxxxxx>
> Signed-off-by: Xiangwu Lai <laixiangwu@xxxxxxxxxxxxxxxxxxxx>

Reviewed-by: Tzung-Bi Shih <tzungbi@xxxxxxxxxx>