[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241217042248.omldhsl4royrfo4o@vireshk-i7>
Date: Tue, 17 Dec 2024 09:52:48 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Ma Ke <make_ruc2021@....com>
Cc: mst@...hat.com, jasowang@...hat.com, xuanzhuo@...ux.alibaba.com,
eperezma@...hat.com, arnd@...db.de, virtualization@...ts.linux.dev,
linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH] virtio: fix reference leak in register_virtio_device()
On 17-12-24, 11:54, Ma Ke wrote:
> When device_add(&dev->dev) failed, calling put_device() to explicitly
> release dev->dev. Otherwise, it could cause double free problem.
>
> Found by code review.
>
> Cc: stable@...r.kernel.org
> Fixes: 694a1116b405 ("virtio: Bind virtio device to device-tree node")
The fixes tag looks incorrect as the problem must be present before this commit
too.
> Signed-off-by: Ma Ke <make_ruc2021@....com>
> ---
> drivers/virtio/virtio.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index b9095751e43b..ac721b5597e8 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -503,6 +503,7 @@ int register_virtio_device(struct virtio_device *dev)
>
> out_of_node_put:
> of_node_put(dev->dev.of_node);
> + put_device(&dev->dev);
> out_ida_remove:
> ida_free(&virtio_index_ida, dev->index);
> out:
> --
> 2.25.1
--
viresh
Powered by blists - more mailing lists