Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [High] Missing `of_node_get()` on `np` causes an OF node reference count 
underflow when the device is unregistered or fails initialization.
--

commit cb36f8cc044a8e4dcecbd3dd967a5ee3d94e60aa
Author: Chaoyi Chen <[email protected]>

drm/bridge: aux: Add drm_aux_bridge_register_from_node()

This patch introduces drm_aux_bridge_register_from_node() to allow
registering an aux bridge with a specific device node pointer. It refactors
drm_aux_bridge_register() to call this new function.

> diff --git a/drivers/gpu/drm/bridge/aux-bridge.c 
> b/drivers/gpu/drm/bridge/aux-bridge.c
> --- 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));
> +     else
> +             device_set_of_node_from_dev(&adev->dev, parent);
>  
>       ret = auxiliary_device_init(adev);
>       if (ret) {
>               of_node_put(adev->dev.of_node);

[Severity: High]
Does this code introduce an OF node refcount underflow when np is provided?

When np is not NULL, device_set_node() is called, which simply assigns the
pointer without acquiring a reference. However, the else branch calls
device_set_of_node_from_dev(), which explicitly calls of_node_get().

If auxiliary_device_init() fails, the error path shown above unconditionally
calls of_node_put(adev->dev.of_node).

Similarly, when the device is destroyed, drm_aux_bridge_release() performs:

drivers/gpu/drm/bridge/aux-bridge.c:drm_aux_bridge_release() {
        struct auxiliary_device *adev = to_auxiliary_dev(dev);

        of_node_put(dev->of_node);
        ...
}

Will this lead to an unbalanced of_node_put() dropping a reference that was
never acquired when a specific device node pointer is passed?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=2

Reply via email to