linux-remoteproc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] rpmsg: Avoid double-free in mtk_rpmsg_register_device
@ 2020-09-03  0:05 Nicolas Boichat
  2020-09-15  5:00 ` patchwork-bot+linux-remoteproc
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Boichat @ 2020-09-03  0:05 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Nicolas Boichat, Mathieu Poirier, Matthias Brugger,
	Ohad Ben-Cohen, Pi-Hsun Shih, linux-arm-kernel, linux-kernel,
	linux-mediatek, linux-remoteproc

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

Fixes: 7017996951fd ("rpmsg: add rpmsg support for mt8183 SCP.")
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---

Changes in v3:
 - 12-char Fixes tag (Mathieu Poirier)

Changes in v2:
 - Drop useless if and ret variable (Markus Elfring)

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

diff --git a/drivers/rpmsg/mtk_rpmsg.c b/drivers/rpmsg/mtk_rpmsg.c
index 83f2b8804ee9..96a17ec29140 100644
--- a/drivers/rpmsg/mtk_rpmsg.c
+++ b/drivers/rpmsg/mtk_rpmsg.c
@@ -200,7 +200,6 @@ static int mtk_rpmsg_register_device(struct mtk_rpmsg_rproc_subdev *mtk_subdev,
 	struct rpmsg_device *rpdev;
 	struct mtk_rpmsg_device *mdev;
 	struct platform_device *pdev = mtk_subdev->pdev;
-	int ret;
 
 	mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
 	if (!mdev)
@@ -219,13 +218,7 @@ static int mtk_rpmsg_register_device(struct mtk_rpmsg_rproc_subdev *mtk_subdev,
 	rpdev->dev.parent = &pdev->dev;
 	rpdev->dev.release = mtk_rpmsg_release_device;
 
-	ret = rpmsg_register_device(rpdev);
-	if (ret) {
-		kfree(mdev);
-		return ret;
-	}
-
-	return 0;
+	return rpmsg_register_device(rpdev);
 }
 
 static void mtk_register_device_work_function(struct work_struct *register_work)
-- 
2.28.0.402.g5ffc5be6b7-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] rpmsg: Avoid double-free in mtk_rpmsg_register_device
  2020-09-03  0:05 [PATCH v3] rpmsg: Avoid double-free in mtk_rpmsg_register_device Nicolas Boichat
@ 2020-09-15  5:00 ` patchwork-bot+linux-remoteproc
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+linux-remoteproc @ 2020-09-15  5:00 UTC (permalink / raw)
  To: Nicolas Boichat; +Cc: linux-remoteproc

Hello:

This patch was applied to andersson/remoteproc.git (refs/heads/for-next).

On Thu,  3 Sep 2020 08:05:58 +0800 you wrote:
> If rpmsg_register_device fails, it will call
> mtk_rpmsg_release_device which already frees mdev.
> 
> Fixes: 7017996951fd ("rpmsg: add rpmsg support for mt8183 SCP.")
> Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> 
> [...]


Here is a summary with links:
  - [v3] rpmsg: Avoid double-free in mtk_rpmsg_register_device
    https://git.kernel.org/andersson/remoteproc/c/231331b2dbd71487159a0400d9ffd967eb0d0e08

You are awesome, thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/pwbot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-15  5:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-03  0:05 [PATCH v3] rpmsg: Avoid double-free in mtk_rpmsg_register_device Nicolas Boichat
2020-09-15  5:00 ` patchwork-bot+linux-remoteproc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).