Message ID | 20210625103437.bb82b95035e4.I748b002f0650d0705e6ae6b4c4f4b63face436f7@changeid |
---|---|
State | Accepted |
Headers | show |
Series | [1/4] um: make PCI emulation driver init/exit static | expand |
On 25/06/2021 09:34, Johannes Berg wrote: > From: Johannes Berg <johannes.berg@intel.com> > > If initialization fails, e.g. because the connection failed, > we leak the 'vu_dev'. Fix that. Reported by smatch. > > Fixes: 5d38f324993f ("um: drivers: Add virtio vhost-user driver") > Signed-off-by: Johannes Berg <johannes.berg@intel.com> > --- > arch/um/drivers/virtio_uml.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c > index cb79fe33d84e..d51e445df797 100644 > --- a/arch/um/drivers/virtio_uml.c > +++ b/arch/um/drivers/virtio_uml.c > @@ -1140,7 +1140,7 @@ static int virtio_uml_probe(struct platform_device *pdev) > rc = os_connect_socket(pdata->socket_path); > } while (rc == -EINTR); > if (rc < 0) > - return rc; > + goto error_free; > vu_dev->sock = rc; > > spin_lock_init(&vu_dev->sock_lock); > @@ -1161,6 +1161,8 @@ static int virtio_uml_probe(struct platform_device *pdev) > > error_init: > os_close_file(vu_dev->sock); > +error_free: > + kfree(vu_dev); > return rc; > } > > Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com>
diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c index cb79fe33d84e..d51e445df797 100644 --- a/arch/um/drivers/virtio_uml.c +++ b/arch/um/drivers/virtio_uml.c @@ -1140,7 +1140,7 @@ static int virtio_uml_probe(struct platform_device *pdev) rc = os_connect_socket(pdata->socket_path); } while (rc == -EINTR); if (rc < 0) - return rc; + goto error_free; vu_dev->sock = rc; spin_lock_init(&vu_dev->sock_lock); @@ -1161,6 +1161,8 @@ static int virtio_uml_probe(struct platform_device *pdev) error_init: os_close_file(vu_dev->sock); +error_free: + kfree(vu_dev); return rc; }