lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220314052855.11852-1-ming.qian@nxp.com>
Date:   Mon, 14 Mar 2022 13:28:55 +0800
From:   Ming Qian <ming.qian@....com>
To:     mchehab@...nel.org, shawnguo@...nel.org
Cc:     hverkuil-cisco@...all.nl, robh+dt@...nel.org,
        s.hauer@...gutronix.de, kernel@...gutronix.de, festevam@...il.com,
        linux-imx@....com, aisheng.dong@....com,
        linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org
Subject: [PATCH] media: amphion: cleanup media device if register it fail

there is issue that driver forget to
call media_device_cleanup if media_device_register fail,
it will led to memory leak.
Also driver should check the return value of vpu_add_func.

Signed-off-by: Ming Qian <ming.qian@....com>
---
 drivers/media/platform/amphion/vpu_drv.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/amphion/vpu_drv.c b/drivers/media/platform/amphion/vpu_drv.c
index f19f823d4b8c..9d5a5075343d 100644
--- a/drivers/media/platform/amphion/vpu_drv.c
+++ b/drivers/media/platform/amphion/vpu_drv.c
@@ -128,8 +128,12 @@ static int vpu_probe(struct platform_device *pdev)
 	vpu->encoder.function = MEDIA_ENT_F_PROC_VIDEO_ENCODER;
 	vpu->decoder.type = VPU_CORE_TYPE_DEC;
 	vpu->decoder.function = MEDIA_ENT_F_PROC_VIDEO_DECODER;
-	vpu_add_func(vpu, &vpu->decoder);
-	vpu_add_func(vpu, &vpu->encoder);
+	ret = vpu_add_func(vpu, &vpu->decoder);
+	if (ret)
+		goto err_add_decoder;
+	ret = vpu_add_func(vpu, &vpu->encoder);
+	if (ret)
+		goto err_add_encoder;
 	ret = media_device_register(&vpu->mdev);
 	if (ret)
 		goto err_vpu_media;
@@ -141,7 +145,10 @@ static int vpu_probe(struct platform_device *pdev)
 
 err_vpu_media:
 	vpu_remove_func(&vpu->encoder);
+err_add_encoder:
 	vpu_remove_func(&vpu->decoder);
+err_add_decoder:
+	media_device_cleanup(&vpu->mdev);
 	v4l2_device_unregister(&vpu->v4l2_dev);
 err_vpu_deinit:
 	pm_runtime_set_suspended(dev);
-- 
2.33.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ