Commit 231331b2 authored by Nicolas Boichat's avatar Nicolas Boichat Committed by Bjorn Andersson

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: 70179969 ("rpmsg: add rpmsg support for mt8183 SCP.")
Signed-off-by: default avatarNicolas Boichat <drinkcat@chromium.org>
Reviewed-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20200903080547.v3.1.I56cf27cd59f4013bd074dc622c8b8248b034a4cc@changeidSigned-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent e69ee0cf
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment