Skip to content

Commit

Permalink
rpmsg: core: Clean up resources on announce_create failure.
Browse files Browse the repository at this point in the history
During the rpmsg_dev_probe, if rpdev->ops->announce_create returns an
error, the rpmsg device and default endpoint should be freed before
exiting the function.

Fixes: 5e619b4 ("rpmsg: Split rpmsg core and virtio backend")
Suggested-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20211206190758.10004-1-arnaud.pouliquen@foss.st.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
  • Loading branch information
arnopo authored and mathieupoirier committed Dec 8, 2021
1 parent 631af6e commit 8066c61
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions drivers/rpmsg/rpmsg_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,25 @@ static int rpmsg_dev_probe(struct device *dev)
err = rpdrv->probe(rpdev);
if (err) {
dev_err(dev, "%s: failed: %d\n", __func__, err);
if (ept)
rpmsg_destroy_ept(ept);
goto out;
goto destroy_ept;
}

if (ept && rpdev->ops->announce_create)
if (ept && rpdev->ops->announce_create) {
err = rpdev->ops->announce_create(rpdev);
if (err) {
dev_err(dev, "failed to announce creation\n");
goto remove_rpdev;
}
}

return 0;

remove_rpdev:
if (rpdrv->remove)
rpdrv->remove(rpdev);
destroy_ept:
if (ept)
rpmsg_destroy_ept(ept);
out:
return err;
}
Expand Down

0 comments on commit 8066c61

Please sign in to comment.