[PATCH v2] media: platform: mtk-mdp3: Fix resource leaks in mdp_get_subsys_id()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a put_device() call for the release of the object
which was determined by a of_find_device_by_node() call.

Signed-off-by: Lu Hongfei <luhongfei@xxxxxxxx>
---
The modifications made compared to the previous version are as follows:
1. Modified the patch subject
2. Modified the commit message to make it easier to understand.
3. Use an additional label "put_device". Increase the usage of the variable "ret".

 drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c | 7 +++++--
 1 file changed, 5 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..ec39662a2282
--- 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,
-- 
2.39.0




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux