[PATCH v5 3/6] drm/bridge: aux: Add drm_aux_bridge_register_from_node()
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Jul 29 18:42:56 PDT 2026
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unbalanced `of_node_put()` on the provided device node `np` leads to reference count underflow and potential use-after-free.
--
--- Patch [3]: [PATCH v5 3/6] drm/bridge: aux: Add drm_aux_bridge_register_from_node() ---
commit 73b014949499087c9b0b99c49dc18c4868428dcd
Author: Chaoyi Chen <chaoyi.chen at rock-chips.com>
drm/bridge: aux: Add drm_aux_bridge_register_from_node()
This patch introduces a new function to register an auxiliary bridge using
a specifically provided device node, instead of defaulting to the parent's
device node.
> diff --git a/drivers/gpu/drm/bridge/aux-bridge.c b/drivers/gpu/drm/bridge/aux-bridge.c
> index 1ed21a8713bfd..06a1466f49bd2 100644
> --- a/drivers/gpu/drm/bridge/aux-bridge.c
> +++ b/drivers/gpu/drm/bridge/aux-bridge.c
[ ... ]
> @@ -62,7 +63,10 @@ int drm_aux_bridge_register(struct device *parent)
> adev->dev.parent = parent;
> adev->dev.release = drm_aux_bridge_release;
>
> - device_set_of_node_from_dev(&adev->dev, parent);
> + if (np)
> + device_set_node(&adev->dev, of_fwnode_handle(np));
[Severity: High]
Does this path cause a reference count underflow on the provided device node?
When np is provided, device_set_node() simply assigns the node pointer
without taking a reference via of_node_get(). In contrast, the fallback
path device_set_of_node_from_dev() properly acquires a reference.
Both the error path below (when auxiliary_device_init() fails) and the
normal device release callback drm_aux_bridge_release() unconditionally
call of_node_put(adev->dev.of_node). This drops a reference that was never
acquired in the np != NULL branch.
If the API intended to consume a reference from the caller, the error
paths appear to be structurally broken: failure in ida_alloc() does not
drop the reference, but failure in auxiliary_device_init() does, leaving
the caller unable to know if it should clean up the reference.
Should we add an of_node_get() here?
> + else
> + device_set_of_node_from_dev(&adev->dev, parent);
>
> ret = auxiliary_device_init(adev);
> if (ret) {
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260730013349.51-1-kernel@airkyi.com?part=3
More information about the linux-phy
mailing list