Re: [PATCH] qemu: Add VIR_FREE in ADD_BITMAP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On a Friday in 2023, Michal Prívozník wrote:
On 9/28/23 13:55, Anastasia Belova wrote:
virBitmapFormat returns the string that should be freed.

All strings in three ADD_BITMAP calls in qemuDomainGetGuestVcpusParams
are contained in tmp. So memory leak is possible here without VIR_FREE.

Fixes: 3e7db8d3e8 ("Remove backslash alignment attempts")

Nothing in that commit suggests the VIR_FREE() was removed. In fact,
digging in our history it was commit
0108deb944af5ca6f1da350c9d0352c8ed18738b which removed the call.

Nit pick: I dislike short hashes because they are not unique. For
instance, this short has is 10 characters, but as our history grows
it'll need to grow too, otherwise it won't be unique. What is unique
though (and both human and machine readable) is: 'git describe --tags'
and if it's older commit then 'git describe --tags --contains'.

But the purpose of 'Fixes' in our commit messages is to help downstream
maintainers. For instance, when I'd be cherry picking that defect
commit, plain search through git log shows what other commits fix it.
Another reason against short hashes.

Signed-off-by: Anastasia Belova <abelova@xxxxxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9e0f204e44..a70bfb6450 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18420,6 +18420,7 @@ qemuDomainGetGuestVcpusParams(virTypedParameterPtr *params,
         goto cleanup; \
     if (virTypedParamsAddString(&par, &npar, &maxpar, #name, tmp) < 0) \
         goto cleanup; \
+    VIR_FREE(tmp); \


tmp is declared as 'g_autofree'. Generally we try to avoid mixing
autofree and manual memory freeing.

But from the functional point of view, it does not matter.

Jano

Nice catch!

We can use this opportunity to:

1) drop the trailing '\' as we don't really need the macro continue on
the next (empty) line,

2) drop the trailing ';' so that ...


     ADD_BITMAP(vcpus);
     ADD_BITMAP(online);

... these calls can retain their semicolons (and in fact enforce them).

Reviewed-by: Michal Privoznik <mprivozn@xxxxxxxxxx>

and pushed.

Michal

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux