Skip to content

Commit 6a4ae7f

Browse files
javiercarrascocruzChun-Kuang Hu
authored andcommitted
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 <[email protected]> Reviewed-by: CK Hu <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 5beb6fb commit 6a4ae7f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,12 @@ static int compare_of(struct device *dev, void *data)
493493
static int ovl_adaptor_comp_init(struct device *dev, struct component_match **match)
494494
{
495495
struct mtk_disp_ovl_adaptor *priv = dev_get_drvdata(dev);
496-
struct device_node *node, *parent;
496+
struct device_node *parent;
497497
struct platform_device *comp_pdev;
498498

499499
parent = dev->parent->parent->of_node->parent;
500500

501-
for_each_child_of_node(parent, node) {
501+
for_each_child_of_node_scoped(parent, node) {
502502
const struct of_device_id *of_id;
503503
enum mtk_ovl_adaptor_comp_type type;
504504
int id;
@@ -522,10 +522,8 @@ static int ovl_adaptor_comp_init(struct device *dev, struct component_match **ma
522522
}
523523

524524
comp_pdev = of_find_device_by_node(node);
525-
if (!comp_pdev) {
526-
of_node_put(node);
525+
if (!comp_pdev)
527526
return -EPROBE_DEFER;
528-
}
529527

530528
priv->ovl_adaptor_comp[id] = &comp_pdev->dev;
531529

0 commit comments

Comments
 (0)