Skip to content

Commit 6914968

Browse files
committed
drm/bridge: properly refcount DT nodes in aux bridge drivers
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 <luca.weiss@fairphone.com> 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 <neil.armstrong@linaro.org> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20231216235910.911958-1-dmitry.baryshkov@linaro.org Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
1 parent 8a53e29 commit 6914968

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

drivers/gpu/drm/bridge/aux-bridge.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
#include <linux/auxiliary_bus.h>
88
#include <linux/module.h>
9+
#include <linux/of.h>
910

1011
#include <drm/drm_bridge.h>
1112
#include <drm/bridge/aux-bridge.h>
@@ -57,7 +58,7 @@ int drm_aux_bridge_register(struct device *parent)
5758
adev->id = ret;
5859
adev->name = "aux_bridge";
5960
adev->dev.parent = parent;
60-
adev->dev.of_node = parent->of_node;
61+
adev->dev.of_node = of_node_get(parent->of_node);
6162
adev->dev.release = drm_aux_bridge_release;
6263

6364
ret = auxiliary_device_init(adev);

drivers/gpu/drm/bridge/aux-hpd-bridge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent,
6868
adev->id = ret;
6969
adev->name = "dp_hpd_bridge";
7070
adev->dev.parent = parent;
71-
adev->dev.of_node = parent->of_node;
71+
adev->dev.of_node = of_node_get(parent->of_node);
7272
adev->dev.release = drm_aux_hpd_bridge_release;
73-
adev->dev.platform_data = np;
73+
adev->dev.platform_data = of_node_get(np);
7474

7575
ret = auxiliary_device_init(adev);
7676
if (ret) {

0 commit comments

Comments
 (0)