diff options
author | Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> | 2021-12-06 20:07:58 +0100 |
---|---|---|
committer | Mathieu Poirier <mathieu.poirier@linaro.org> | 2021-12-08 10:16:50 -0700 |
commit | 8066c615cb69b7da8a94f59379847b037b3a5e46 (patch) | |
tree | b5fc89f1458864316d1ee966b6342a6bd10aa06e /drivers/rpmsg/rpmsg_core.c | |
parent | 631af6e0f41002dc63504efd2f6c3e1ab5f931c5 (diff) |
rpmsg: core: Clean up resources on announce_create failure.
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: 5e619b48677c ("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>
Diffstat (limited to 'drivers/rpmsg/rpmsg_core.c')
-rw-r--r-- | drivers/rpmsg/rpmsg_core.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index f031b2b1b21c..d9e612f4f0f2 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -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; } |