* Re: [PATCH v2] virtio: fix reference leak in register_virtio_device()
[not found] <20241218031201.2968918-1-make_ruc2021@163.com>
@ 2024-12-18 8:00 ` Markus Elfring
0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2024-12-18 8:00 UTC (permalink / raw)
To: make_ruc2021, virtualization, kernel-janitors, Cornelia Huck,
Eugenio Pérez, Jason Wang, Michael S. Tsirkin, weiping zhang,
Xuan Zhuo
Cc: linux-kernel, stable
> 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-12-18 8:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20241218031201.2968918-1-make_ruc2021@163.com>
2024-12-18 8:00 ` [PATCH v2] virtio: fix reference leak in register_virtio_device() Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox