[PATCH] rpmsg: Avoid double-free in mtk_rpmsg_register_device

Nicolas Boichat drinkcat at chromium.org
Wed Sep 2 03:03:19 EDT 2020


If rpmsg_register_device fails, it will call
mtk_rpmsg_release_device which already frees mdev.

Fixes: 7017996951fde84 ("rpmsg: add rpmsg support for mt8183 SCP.")
Signed-off-by: Nicolas Boichat <drinkcat at chromium.org>
---

 drivers/rpmsg/mtk_rpmsg.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/rpmsg/mtk_rpmsg.c b/drivers/rpmsg/mtk_rpmsg.c
index 83f2b8804ee989d..f43b69c00e8aa44 100644
--- a/drivers/rpmsg/mtk_rpmsg.c
+++ b/drivers/rpmsg/mtk_rpmsg.c
@@ -220,10 +220,8 @@ static int mtk_rpmsg_register_device(struct mtk_rpmsg_rproc_subdev *mtk_subdev,
 	rpdev->dev.release = mtk_rpmsg_release_device;
 
 	ret = rpmsg_register_device(rpdev);
-	if (ret) {
-		kfree(mdev);
+	if (ret)
 		return ret;
-	}
 
 	return 0;
 }
-- 
2.28.0.402.g5ffc5be6b7-goog




More information about the Linux-mediatek mailing list