summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
diff options
context:
space:
mode:
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>2024-06-24 19:43:48 +0300
committerChun-Kuang Hu <chunkuang.hu@kernel.org>2024-08-15 16:53:00 +0300
commit6a4ae7f095aae36ec3211fb6efd1a10b35b0fb8e (patch)
tree3f69f22cc4d7174de4d5545de1ff3cd37079ac55 /drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
parent5beb6fba25db235b52eab34bde8112f07bb31d75 (diff)
downloadlinux-6a4ae7f095aae36ec3211fb6efd1a10b35b0fb8e.tar.xz
drm/mediatek: ovl_adaptor: Use scoped variant of for_each_child_of_node()
In order to avoid potential memory leaks if new error paths are added without a call to of_node_put(), use for_each_child_of_node_scoped() instead of for_each_child_of_node(). The former automatically decrements the refcount when the child goes out of scope, which removes the need for explicit calls to of_node_put(). Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Reviewed-by: CK Hu <ck.hu@mediatek.com> Link: https://patchwork.kernel.org/project/dri-devel/patch/20240624-mtk_disp_ovl_adaptor_scoped-v1-3-9fa1e074d881@gmail.com/ Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Diffstat (limited to 'drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c')
-rw-r--r--drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
index 436c1af4c992..c6768210b08b 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
@@ -493,12 +493,12 @@ static int compare_of(struct device *dev, void *data)
static int ovl_adaptor_comp_init(struct device *dev, struct component_match **match)
{
struct mtk_disp_ovl_adaptor *priv = dev_get_drvdata(dev);
- struct device_node *node, *parent;
+ struct device_node *parent;
struct platform_device *comp_pdev;
parent = dev->parent->parent->of_node->parent;
- for_each_child_of_node(parent, node) {
+ for_each_child_of_node_scoped(parent, node) {
const struct of_device_id *of_id;
enum mtk_ovl_adaptor_comp_type type;
int id;
@@ -522,10 +522,8 @@ static int ovl_adaptor_comp_init(struct device *dev, struct component_match **ma
}
comp_pdev = of_find_device_by_node(node);
- if (!comp_pdev) {
- of_node_put(node);
+ if (!comp_pdev)
return -EPROBE_DEFER;
- }
priv->ovl_adaptor_comp[id] = &comp_pdev->dev;