[PATCH 0/2] hw: fix qdev_get_printable_name() leak

Peter Maydell posted 2 patches 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260307155046.3940197-1-peter.maydell@linaro.org
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, "Michael S. Tsirkin" <mst@redhat.com>
hw/core/qdev.c         |  4 ++--
hw/virtio/virtio.c     | 12 +++++++++---
include/hw/core/qdev.h | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 5 deletions(-)
[PATCH 0/2] hw: fix qdev_get_printable_name() leak
Posted by Peter Maydell 1 month ago
The qdev_get_printable_name() function is currently unusable without
leaking memory, because sometimes it returns a string that must be
freed and sometimes a string that must not be freed.

Fix this by making it always return a string that the caller must
free.

Patch 1 addresses an underlying cause of this -- we didn't document
qdev_get_dev_path() and in particular didn't document that its
return value is a string the caller must free.

thanks
-- PMM

Peter Maydell (2):
  hw/qdev: Document qdev_get_dev_path()
  hw: Make qdev_get_printable_name() consistently return freeable string

 hw/core/qdev.c         |  4 ++--
 hw/virtio/virtio.c     | 12 +++++++++---
 include/hw/core/qdev.h | 39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 5 deletions(-)

-- 
2.43.0
Re: [PATCH 0/2] hw: fix qdev_get_printable_name() leak
Posted by Philippe Mathieu-Daudé 1 month ago
On 7/3/26 16:50, Peter Maydell wrote:

> Peter Maydell (2):
>    hw/qdev: Document qdev_get_dev_path()
>    hw: Make qdev_get_printable_name() consistently return freeable string

Series queued via hw-misc, thanks.