[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20200902150309.1.I56cf27cd59f4013bd074dc622c8b8248b034a4cc@changeid>
Date: Wed, 2 Sep 2020 15:03:19 +0800
From: Nicolas Boichat <drinkcat@...omium.org>
To: Bjorn Andersson <bjorn.andersson@...aro.org>
Cc: Nicolas Boichat <drinkcat@...omium.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Ohad Ben-Cohen <ohad@...ery.com>,
Pi-Hsun Shih <pihsun@...omium.org>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-mediatek@...ts.infradead.org,
linux-remoteproc@...r.kernel.org
Subject: [PATCH] rpmsg: Avoid double-free in mtk_rpmsg_register_device
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@...omium.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
Powered by blists - more mailing lists