[PATCH RFC v2 01/11] remoteproc: virtio: cleanup rproc_add_virtio_dev error path
Francesco Valla
francesco at valla.it
Sun Nov 1 15:26:38 PST 2026
There is no cleanup to perform in case an error occurs inside
rproc_add_virtio_dev, so remove the goto label and just return in such
cases.
Signed-off-by: Francesco Valla <francesco at valla.it>
---
drivers/remoteproc/remoteproc_virtio.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index 12f55a81cfa0..a86c9a949e4c 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -386,9 +386,8 @@ static int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
int ret;
if (rproc->ops->kick == NULL) {
- ret = -EINVAL;
dev_err(dev, ".kick method not defined for %s\n", rproc->name);
- goto out;
+ return -EINVAL;
}
/* Try to find dedicated vdev buffer carveout */
@@ -404,7 +403,7 @@ static int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
mem->of_resm_idx);
if (ret) {
dev_err(dev, "Can't associate reserved memory\n");
- goto out;
+ return ret;
}
} else {
if (mem->va) {
@@ -422,7 +421,7 @@ static int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
mem->len);
if (ret < 0) {
dev_err(dev, "Failed to associate buffer\n");
- goto out;
+ return ret;
}
}
} else {
@@ -441,10 +440,9 @@ static int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
/* Allocate virtio device */
vdev = kzalloc_obj(*vdev);
- if (!vdev) {
- ret = -ENOMEM;
- goto out;
- }
+ if (!vdev)
+ return -ENOMEM;
+
vdev->id.device = id,
vdev->config = &rproc_virtio_config_ops,
vdev->dev.parent = dev;
@@ -457,13 +455,12 @@ static int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
if (ret) {
put_device(&vdev->dev);
dev_err(dev, "failed to register vdev: %d\n", ret);
- goto out;
+ return ret;
}
dev_info(dev, "registered %s (type %d)\n", dev_name(&vdev->dev), id);
-out:
- return ret;
+ return 0;
}
/**
--
2.56.0
More information about the linux-arm-kernel
mailing list