[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230613032734.34099-1-luhongfei@vivo.com>
Date: Tue, 13 Jun 2023 11:27:27 +0800
From: Lu Hongfei <luhongfei@...o.com>
To: Mauro Carvalho Chehab <mchehab@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>,
Hans Verkuil <hverkuil-cisco@...all.nl>,
Moudy Ho <moudy.ho@...iatek.com>,
Ping-Hsun Wu <ping-hsun.wu@...iatek.com>,
daoyuan huang <daoyuan.huang@...iatek.com>,
Arnd Bergmann <arnd@...db.de>, Lu Hongfei <luhongfei@...o.com>,
Sun Ke <sunke32@...wei.com>,
linux-media@...r.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE
(V4L/DVB)),
linux-kernel@...r.kernel.org (open list:ARM/Mediatek SoC support),
linux-arm-kernel@...ts.infradead.org (moderated list:ARM/Mediatek SoC
support),
linux-mediatek@...ts.infradead.org (moderated list:ARM/Mediatek SoC
support)
Cc: opensource.kernel@...o.com
Subject: [PATCH v3] media: platform: mtk-mdp3: Fix resource leak in mdp_get_subsys_id() and mdp_comp_config()
Add a put_device() call for the release of the object
which was determined by a of_find_device_by_node() call
in mdp_get_subsys_id().
Add of_node_put() call for the release of the object
which was determined by a for_each_child_of_node() call
in mdp_comp_config().
Signed-off-by: Lu Hongfei <luhongfei@...o.com>
---
The previous version’s Subject was:
[PATCH v2] media: platform: mtk-mdp3: Fix resource leaks in mdp_get_subsys_id()
The modifications made compared to the previous version are as follows:
1. Modified the patch subject
2. Fix resource leak issue in mdp_comp_config()
drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
index a605e80c7dc3..85c5f89f2ed2
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c
@@ -892,13 +892,16 @@ static int mdp_get_subsys_id(struct mdp_dev *mdp, struct device *dev,
ret = cmdq_dev_get_client_reg(&comp_pdev->dev, &cmdq_reg, index);
if (ret != 0) {
dev_err(&comp_pdev->dev, "cmdq_dev_get_subsys fail!\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto put_device;
}
comp->subsys_id = cmdq_reg.subsys;
dev_dbg(&comp_pdev->dev, "subsys id=%d\n", cmdq_reg.subsys);
- return 0;
+put_device:
+ put_device(&comp_pdev->dev);
+ return ret;
}
static void __mdp_comp_init(struct mdp_dev *mdp, struct device_node *node,
@@ -1135,6 +1138,7 @@ int mdp_comp_config(struct mdp_dev *mdp)
comp = mdp_comp_create(mdp, node, id);
if (IS_ERR(comp)) {
ret = PTR_ERR(comp);
+ of_node_put(node);
goto err_init_comps;
}
@@ -1144,6 +1148,8 @@ int mdp_comp_config(struct mdp_dev *mdp)
pm_runtime_enable(comp->comp_dev);
}
+ of_node_put(node);
+
ret = mdp_comp_sub_create(mdp);
if (ret)
goto err_init_comps;
--
2.39.0
Powered by blists - more mailing lists