[PATCH] qemu-keymap: Free xkb allocations

Akihiko Odaki posted 1 patch 2 weeks, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240501-xkb-v1-1-f046d8e11a2b@daynix.com
qemu-keymap.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] qemu-keymap: Free xkb allocations
Posted by Akihiko Odaki 2 weeks, 2 days ago
This fixes LeakSanitizer complaints with xkbcommon 1.6.0.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 qemu-keymap.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qemu-keymap.c b/qemu-keymap.c
index 8c80f7a4ed65..7a9f38cf9863 100644
--- a/qemu-keymap.c
+++ b/qemu-keymap.c
@@ -237,6 +237,9 @@ int main(int argc, char *argv[])
     xkb_state_unref(state);
     state = NULL;
 
+    xkb_keymap_unref(map);
+    xkb_context_unref(ctx);
+
     /* add quirks */
     fprintf(outfile,
             "\n"

---
base-commit: c25df57ae8f9fe1c72eee2dab37d76d904ac382e
change-id: 20240501-xkb-258483ccc5d8

Best regards,
-- 
Akihiko Odaki <akihiko.odaki@daynix.com>
Re: [PATCH] qemu-keymap: Free xkb allocations
Posted by Michael Tokarev 1 week, 5 days ago
01.05.2024 10:55, Akihiko Odaki wrote:
> This fixes LeakSanitizer complaints with xkbcommon 1.6.0.
> 
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
>   qemu-keymap.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/qemu-keymap.c b/qemu-keymap.c
> index 8c80f7a4ed65..7a9f38cf9863 100644
> --- a/qemu-keymap.c
> +++ b/qemu-keymap.c
> @@ -237,6 +237,9 @@ int main(int argc, char *argv[])
>       xkb_state_unref(state);
>       state = NULL;
>   
> +    xkb_keymap_unref(map);
> +    xkb_context_unref(ctx);
> +

I'd avoid freeing any resources in main() entirely,
since it's much cheaper to free whole process by the
kernel at exit time than to mess with each chunk of
allocated memory.  Dunno how useful it is to "fix"
these.

/mjt

>       /* add quirks */
>       fprintf(outfile,
>               "\n"
> 
> ---
> base-commit: c25df57ae8f9fe1c72eee2dab37d76d904ac382e
> change-id: 20240501-xkb-258483ccc5d8
> 
> Best regards,

-- 
GPG Key transition (from rsa2048 to rsa4096) since 2024-04-24.
New key: rsa4096/61AD3D98ECDF2C8E  9D8B E14E 3F2A 9DD7 9199  28F1 61AD 3D98 ECDF 2C8E
Old key: rsa2048/457CE0A0804465C5  6EE1 95D1 886E 8FFB 810D  4324 457C E0A0 8044 65C5
Transition statement: http://www.corpit.ru/mjt/gpg-transition-2024.txt
Re: [PATCH] qemu-keymap: Free xkb allocations
Posted by Akihiko Odaki 1 week, 5 days ago
On 2024/05/05 19:24, Michael Tokarev wrote:
> 01.05.2024 10:55, Akihiko Odaki wrote:
>> This fixes LeakSanitizer complaints with xkbcommon 1.6.0.
>>
>> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>> ---
>>   qemu-keymap.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/qemu-keymap.c b/qemu-keymap.c
>> index 8c80f7a4ed65..7a9f38cf9863 100644
>> --- a/qemu-keymap.c
>> +++ b/qemu-keymap.c
>> @@ -237,6 +237,9 @@ int main(int argc, char *argv[])
>>       xkb_state_unref(state);
>>       state = NULL;
>> +    xkb_keymap_unref(map);
>> +    xkb_context_unref(ctx);
>> +
> 
> I'd avoid freeing any resources in main() entirely,
> since it's much cheaper to free whole process by the
> kernel at exit time than to mess with each chunk of
> allocated memory.  Dunno how useful it is to "fix"
> these.
> 
> /mjt

This is purely to satisfy LeakSanitizier; the LeakSanitizer complaints 
result in a build failure with many noisy logs. I don't add Fixes: tags 
for this kind of leaks.

Regards,
Akihiko Odaki