[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e8dd155b-c907-4874-bd78-af768dc507a5@web.de>
Date: Wed, 18 Dec 2024 09:00:27 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: make_ruc2021@....com, virtualization@...ts.linux.dev,
kernel-janitors@...r.kernel.org, Cornelia Huck <cohuck@...hat.com>,
Eugenio Pérez <eperezma@...hat.com>,
Jason Wang <jasowang@...hat.com>, "Michael S. Tsirkin" <mst@...hat.com>,
weiping zhang <zhangweiping@...ichuxing.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
Cc: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH v2] virtio: fix reference leak in register_virtio_device()
> Once device_add(&dev->dev) failed, call put_device() to explicitly
> release dev->dev. Or it could cause double free problem.
https://elixir.bootlin.com/linux/v6.13-rc3/source/drivers/base/core.c#L3521
…
> Found by code review.
https://elixir.bootlin.com/linux/v6.13-rc3/source/drivers/virtio/virtio.c#L498
Will possibilities become interesting to improve automated source code analyses accordingly?
…
> +++ 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:
How much can the ordering matter for such resource cleanup calls here?
Regards,
Markus
Powered by blists - more mailing lists