From: Markus Elfring <Markus.Elfring@web.de>
To: make_ruc2021@163.com, virtualization@lists.linux.dev,
kernel-janitors@vger.kernel.org,
"Cornelia Huck" <cohuck@redhat.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"weiping zhang" <zhangweiping@didichuxing.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] virtio: fix reference leak in register_virtio_device()
Date: Wed, 18 Dec 2024 09:00:27 +0100 [thread overview]
Message-ID: <e8dd155b-c907-4874-bd78-af768dc507a5@web.de> (raw)
In-Reply-To: <20241218031201.2968918-1-make_ruc2021@163.com>
> 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
next prev parent reply other threads:[~2024-12-18 8:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-18 3:12 [PATCH v2] virtio: fix reference leak in register_virtio_device() Ma Ke
2024-12-18 8:00 ` Markus Elfring [this message]
2024-12-18 9:18 ` Michael S. Tsirkin
-- strict thread matches above, loose matches on Subject: below --
2024-12-17 7:17 Ma Ke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e8dd155b-c907-4874-bd78-af768dc507a5@web.de \
--to=markus.elfring@web.de \
--cc=cohuck@redhat.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=make_ruc2021@163.com \
--cc=mst@redhat.com \
--cc=stable@vger.kernel.org \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
--cc=zhangweiping@didichuxing.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox