rproc_virtio_dev_release will be called iff virtio_device.dev's refer count became to 0. Here we should check if we call device_register or not, if called, put vdev.dev, and then rproc->dev's cleanup will be done in rproc_virtio_dev_release, otherwise we do cleanup directly. Signed-off-by: weiping zhang <zhangweiping@xxxxxxxxxxxxxxx> --- drivers/remoteproc/remoteproc_virtio.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index 2946348..ad5d6d1 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -327,14 +327,22 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) ret = register_virtio_device(vdev); if (ret) { - put_device(&rproc->dev); dev_err(dev, "failed to register vdev: %d\n", ret); goto out; } dev_info(dev, "registered %s (type %d)\n", dev_name(&vdev->dev), id); + return 0; + out: + if (VIRTIO_CONFIG_S_ACKNOWLEDGE & virtio_get_status(vdev)) + put_device(&vdev->dev); + else { + kref_put(&rvdev->refcount, rproc_vdev_release); + put_device(&rproc->dev); + } + return ret; } -- 2.9.4 _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization