The main fix is a possible memory leak on an early exit in the for_each_child_of_node() loop. That fix has been divided into a patch that can be backported (a simple of_node_put()), and another one that uses the scoped variant of the macro, removing the need for any of_node_put(). That prevents mistakes if new break/return instructions are added, but the macro might not be available in older kernels.
When at it, an unused header has been dropped.
Signed-off-by: Javier Carrasco javier.carrasco.cruz@gmail.com --- Javier Carrasco (3): drm/mediatek: ovl_adaptor: drop unused mtk_crtc.h header drm/mediatek: ovl_adaptor: add missing of_node_put() drm/mediatek: ovl_adaptor: use scoped variant of for_each_child_of_node()
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- base-commit: f76698bd9a8ca01d3581236082d786e9a6b72bb7 change-id: 20240624-mtk_disp_ovl_adaptor_scoped-0702a6b23443
Best regards,
Error paths that exit for_each_child_of_node() need to call of_node_put() to decerement the child refcount and avoid memory leaks.
Add the missing of_node_put().
Cc: stable@vger.kernel.org Fixes: 453c3364632a ("drm/mediatek: Add ovl_adaptor support for MT8195") Signed-off-by: Javier Carrasco javier.carrasco.cruz@gmail.com --- drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c index 1418992311c4..3faf26a55e77 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c @@ -522,8 +522,10 @@ static int ovl_adaptor_comp_init(struct device *dev, struct component_match **ma }
comp_pdev = of_find_device_by_node(node); - if (!comp_pdev) + if (!comp_pdev) { + of_node_put(node); return -EPROBE_DEFER; + }
priv->ovl_adaptor_comp[id] = &comp_pdev->dev;
Hi, Javier:
On Mon, 2024-06-24 at 18:43 +0200, Javier Carrasco wrote:
External email : Please do not click links or open attachments until you have verified the sender or the content. Error paths that exit for_each_child_of_node() need to call of_node_put() to decerement the child refcount and avoid memory leaks.
Add the missing of_node_put().
Reviewed-by: CK Hu ck.hu@mediatek.com
Cc: stable@vger.kernel.org Fixes: 453c3364632a ("drm/mediatek: Add ovl_adaptor support for MT8195") Signed-off-by: Javier Carrasco javier.carrasco.cruz@gmail.com
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c index 1418992311c4..3faf26a55e77 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c @@ -522,8 +522,10 @@ static int ovl_adaptor_comp_init(struct device *dev, struct component_match **ma } comp_pdev = of_find_device_by_node(node); -if (!comp_pdev) +if (!comp_pdev) { +of_node_put(node); return -EPROBE_DEFER; +} priv->ovl_adaptor_comp[id] = &comp_pdev->dev;
-- 2.40.1
Hi, Javier:
Javier Carrasco javier.carrasco.cruz@gmail.com 於 2024年6月25日 週二 上午12:44寫道:
The main fix is a possible memory leak on an early exit in the for_each_child_of_node() loop. That fix has been divided into a patch that can be backported (a simple of_node_put()), and another one that uses the scoped variant of the macro, removing the need for any of_node_put(). That prevents mistakes if new break/return instructions are added, but the macro might not be available in older kernels.
When at it, an unused header has been dropped.
For this series, applied to mediatek-drm-next [1], thanks.
Regards, CK
[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?...
Signed-off-by: Javier Carrasco javier.carrasco.cruz@gmail.com
Javier Carrasco (3): drm/mediatek: ovl_adaptor: drop unused mtk_crtc.h header drm/mediatek: ovl_adaptor: add missing of_node_put() drm/mediatek: ovl_adaptor: use scoped variant of for_each_child_of_node()
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
base-commit: f76698bd9a8ca01d3581236082d786e9a6b72bb7 change-id: 20240624-mtk_disp_ovl_adaptor_scoped-0702a6b23443
Best regards,
Javier Carrasco javier.carrasco.cruz@gmail.com
linux-stable-mirror@lists.linaro.org