* [PATCH] hw/s390x/ccw-device: Fix memory leak in loadparm setter
@ 2025-06-25 8:27 Kevin Wolf
2025-06-25 13:15 ` Eric Farman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Kevin Wolf @ 2025-06-25 8:27 UTC (permalink / raw)
To: qemu-devel
Cc: kwolf, pasic, borntraeger, farman, thuth, qemu-s390x,
qemu-trivial
Commit bdf12f2a fixed the setter for the "loadparm" machine property,
which gets a string from a visitor, passes it to s390_ipl_fmt_loadparm()
and then forgot to free it. It left another instance of the same problem
unfixed in the "loadparm" device property. Fix it.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hw/s390x/ccw-device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/s390x/ccw-device.c b/hw/s390x/ccw-device.c
index 19c2238f76..8be1813b9e 100644
--- a/hw/s390x/ccw-device.c
+++ b/hw/s390x/ccw-device.c
@@ -57,7 +57,7 @@ static void ccw_device_set_loadparm(Object *obj, Visitor *v,
Error **errp)
{
CcwDevice *dev = CCW_DEVICE(obj);
- char *val;
+ g_autofree char *val = NULL;
int index;
index = object_property_get_int(obj, "bootindex", NULL);
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/s390x/ccw-device: Fix memory leak in loadparm setter
2025-06-25 8:27 [PATCH] hw/s390x/ccw-device: Fix memory leak in loadparm setter Kevin Wolf
@ 2025-06-25 13:15 ` Eric Farman
2025-06-25 13:36 ` Thomas Huth
2025-06-25 22:19 ` Halil Pasic
2 siblings, 0 replies; 4+ messages in thread
From: Eric Farman @ 2025-06-25 13:15 UTC (permalink / raw)
To: Kevin Wolf, qemu-devel
Cc: pasic, borntraeger, thuth, qemu-s390x, qemu-trivial
On Wed, 2025-06-25 at 10:27 +0200, Kevin Wolf wrote:
> Commit bdf12f2a fixed the setter for the "loadparm" machine property,
> which gets a string from a visitor, passes it to s390_ipl_fmt_loadparm()
> and then forgot to free it. It left another instance of the same problem
> unfixed in the "loadparm" device property. Fix it.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> hw/s390x/ccw-device.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Eric Farman <farman@linux.ibm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/s390x/ccw-device: Fix memory leak in loadparm setter
2025-06-25 8:27 [PATCH] hw/s390x/ccw-device: Fix memory leak in loadparm setter Kevin Wolf
2025-06-25 13:15 ` Eric Farman
@ 2025-06-25 13:36 ` Thomas Huth
2025-06-25 22:19 ` Halil Pasic
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Huth @ 2025-06-25 13:36 UTC (permalink / raw)
To: Kevin Wolf, qemu-devel
Cc: pasic, borntraeger, farman, qemu-s390x, qemu-trivial,
Fabiano Rosas, Eric Farman
On 25/06/2025 10.27, Kevin Wolf wrote:
> Commit bdf12f2a fixed the setter for the "loadparm" machine property,
> which gets a string from a visitor, passes it to s390_ipl_fmt_loadparm()
> and then forgot to free it. It left another instance of the same problem
> unfixed in the "loadparm" device property. Fix it.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> hw/s390x/ccw-device.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/s390x/ccw-device.c b/hw/s390x/ccw-device.c
> index 19c2238f76..8be1813b9e 100644
> --- a/hw/s390x/ccw-device.c
> +++ b/hw/s390x/ccw-device.c
> @@ -57,7 +57,7 @@ static void ccw_device_set_loadparm(Object *obj, Visitor *v,
> Error **errp)
> {
> CcwDevice *dev = CCW_DEVICE(obj);
> - char *val;
> + g_autofree char *val = NULL;
> int index;
I was able to reproduce the leak with a command line like this:
valgrind --trace-children=yes --track-origins=yes --leak-check=full \
--show-leak-kinds=definite ./qemu-system-s390x -nographic -accel kvm \
-drive if=none,file=/tmp/disk0.qcow2,format=qcow2,id=drive_image1 \
-device virtio-blk-ccw,drive="drive_image1",bootindex=0,loadparm=4 \
-device virtio-scsi-ccw
And I can confirm that your patch fixes the issue, thank you!
Tested-by: Thomas Huth <thuth@redhat.com>
I'll queue it for my next pull request.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/s390x/ccw-device: Fix memory leak in loadparm setter
2025-06-25 8:27 [PATCH] hw/s390x/ccw-device: Fix memory leak in loadparm setter Kevin Wolf
2025-06-25 13:15 ` Eric Farman
2025-06-25 13:36 ` Thomas Huth
@ 2025-06-25 22:19 ` Halil Pasic
2 siblings, 0 replies; 4+ messages in thread
From: Halil Pasic @ 2025-06-25 22:19 UTC (permalink / raw)
To: Kevin Wolf
Cc: qemu-devel, borntraeger, farman, thuth, qemu-s390x, qemu-trivial,
Halil Pasic
On Wed, 25 Jun 2025 10:27:51 +0200
Kevin Wolf <kwolf@redhat.com> wrote:
> Commit bdf12f2a fixed the setter for the "loadparm" machine property,
> which gets a string from a visitor, passes it to s390_ipl_fmt_loadparm()
> and then forgot to free it. It left another instance of the same problem
> unfixed in the "loadparm" device property. Fix it.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-25 22:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-25 8:27 [PATCH] hw/s390x/ccw-device: Fix memory leak in loadparm setter Kevin Wolf
2025-06-25 13:15 ` Eric Farman
2025-06-25 13:36 ` Thomas Huth
2025-06-25 22:19 ` Halil Pasic
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).