* [PATCH] rpmsg: core: Clean up resources on announce_create failure.
@ 2021-12-06 19:07 Arnaud Pouliquen
2021-12-06 19:26 ` Bjorn Andersson
2021-12-08 17:27 ` Mathieu Poirier
0 siblings, 2 replies; 3+ messages in thread
From: Arnaud Pouliquen @ 2021-12-06 19:07 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier
Cc: linux-remoteproc, linux-kernel, linux-stm32, arnaud.pouliquen
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>
---
drivers/rpmsg/rpmsg_core.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
index 27aad6baf7c5..12d7b7c6e5f9 100644
--- a/drivers/rpmsg/rpmsg_core.c
+++ b/drivers/rpmsg/rpmsg_core.c
@@ -612,13 +612,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;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] rpmsg: core: Clean up resources on announce_create failure.
2021-12-06 19:07 [PATCH] rpmsg: core: Clean up resources on announce_create failure Arnaud Pouliquen
@ 2021-12-06 19:26 ` Bjorn Andersson
2021-12-08 17:27 ` Mathieu Poirier
1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2021-12-06 19:26 UTC (permalink / raw)
To: Arnaud Pouliquen
Cc: Mathieu Poirier, linux-remoteproc, linux-kernel, linux-stm32
On Mon 06 Dec 13:07 CST 2021, Arnaud Pouliquen wrote:
> 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>
Thanks,
Bjorn
> ---
> drivers/rpmsg/rpmsg_core.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
> index 27aad6baf7c5..12d7b7c6e5f9 100644
> --- a/drivers/rpmsg/rpmsg_core.c
> +++ b/drivers/rpmsg/rpmsg_core.c
> @@ -612,13 +612,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;
> }
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rpmsg: core: Clean up resources on announce_create failure.
2021-12-06 19:07 [PATCH] rpmsg: core: Clean up resources on announce_create failure Arnaud Pouliquen
2021-12-06 19:26 ` Bjorn Andersson
@ 2021-12-08 17:27 ` Mathieu Poirier
1 sibling, 0 replies; 3+ messages in thread
From: Mathieu Poirier @ 2021-12-08 17:27 UTC (permalink / raw)
To: Arnaud Pouliquen
Cc: Bjorn Andersson, linux-remoteproc, linux-kernel, linux-stm32
On Mon, Dec 06, 2021 at 08:07:58PM +0100, Arnaud Pouliquen wrote:
> 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>
> ---
> drivers/rpmsg/rpmsg_core.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
> index 27aad6baf7c5..12d7b7c6e5f9 100644
> --- a/drivers/rpmsg/rpmsg_core.c
> +++ b/drivers/rpmsg/rpmsg_core.c
> @@ -612,13 +612,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;
Applied.
Thanks,
Mathieu
> }
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-08 17:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06 19:07 [PATCH] rpmsg: core: Clean up resources on announce_create failure Arnaud Pouliquen
2021-12-06 19:26 ` Bjorn Andersson
2021-12-08 17:27 ` Mathieu Poirier
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).