Skip to content

Commit 6977cc8

Browse files
tititiou36robclark
authored andcommitted
drm/msm/dsi: Fix some reference counted resource leaks
'of_find_device_by_node()' takes a reference that must be released when not needed anymore. This is expected to be done in 'dsi_destroy()'. However, there are 2 issues in 'dsi_get_phy()'. First, if 'of_find_device_by_node()' succeeds but 'platform_get_drvdata()' returns NULL, 'msm_dsi->phy_dev' will still be NULL, and the reference won't be released in 'dsi_destroy()'. Secondly, as 'of_find_device_by_node()' already takes a reference, there is no need for an additional 'get_device()'. Move the assignment to 'msm_dsi->phy_dev' a few lines above and remove the unneeded 'get_device()' to solve both issues. Fixes: ec31abf ("drm/msm/dsi: Separate PHY to another platform device") Signed-off-by: Christophe JAILLET <[email protected]> Link: https://lore.kernel.org/r/f15bc57648a00e7c99f943903468a04639d50596.1628241097.git.christophe.jaillet@wanadoo.fr Signed-off-by: Rob Clark <[email protected]>
1 parent f3a6b02 commit 6977cc8

File tree

1 file changed

+3
-3
lines changed
  • drivers/gpu/drm/msm/dsi

1 file changed

+3
-3
lines changed

drivers/gpu/drm/msm/dsi/dsi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ static int dsi_get_phy(struct msm_dsi *msm_dsi)
3333
}
3434

3535
phy_pdev = of_find_device_by_node(phy_node);
36-
if (phy_pdev)
36+
if (phy_pdev) {
3737
msm_dsi->phy = platform_get_drvdata(phy_pdev);
38+
msm_dsi->phy_dev = &phy_pdev->dev;
39+
}
3840

3941
of_node_put(phy_node);
4042

@@ -43,8 +45,6 @@ static int dsi_get_phy(struct msm_dsi *msm_dsi)
4345
return -EPROBE_DEFER;
4446
}
4547

46-
msm_dsi->phy_dev = get_device(&phy_pdev->dev);
47-
4848
return 0;
4949
}
5050

0 commit comments

Comments
 (0)