Skip to content

Commit

Permalink
drm/bridge: properly refcount DT nodes in aux bridge drivers
Browse files Browse the repository at this point in the history
The aux-bridge and aux-hpd-bridge drivers didn't call of_node_get() on
the device nodes further used for dev->of_node and platform data. When
bridge devices are released, the reference counts are decreased,
resulting in refcount underflow / use-after-free warnings. Get
corresponding refcounts during AUX bridge allocation.

Reported-by: Luca Weiss <[email protected]>
Fixes: 2a04739 ("drm/bridge: add transparent bridge helper")
Fixes: 26f4bac ("drm/bridge: aux-hpd: Replace of_device.h with explicit include")
Reviewed-by: Neil Armstrong <[email protected]>
Signed-off-by: Dmitry Baryshkov <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Dmitry Baryshkov <[email protected]>
  • Loading branch information
lumag committed Dec 19, 2023
1 parent 8a53e29 commit 6914968
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion drivers/gpu/drm/bridge/aux-bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
#include <linux/auxiliary_bus.h>
#include <linux/module.h>
#include <linux/of.h>

#include <drm/drm_bridge.h>
#include <drm/bridge/aux-bridge.h>
Expand Down Expand Up @@ -57,7 +58,7 @@ int drm_aux_bridge_register(struct device *parent)
adev->id = ret;
adev->name = "aux_bridge";
adev->dev.parent = parent;
adev->dev.of_node = parent->of_node;
adev->dev.of_node = of_node_get(parent->of_node);
adev->dev.release = drm_aux_bridge_release;

ret = auxiliary_device_init(adev);
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/bridge/aux-hpd-bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent,
adev->id = ret;
adev->name = "dp_hpd_bridge";
adev->dev.parent = parent;
adev->dev.of_node = parent->of_node;
adev->dev.of_node = of_node_get(parent->of_node);
adev->dev.release = drm_aux_hpd_bridge_release;
adev->dev.platform_data = np;
adev->dev.platform_data = of_node_get(np);

ret = auxiliary_device_init(adev);
if (ret) {
Expand Down

0 comments on commit 6914968

Please sign in to comment.