[PATCH] qemu-keymap: fix a small leak

marcandre.lureau@redhat.com posted 1 patch 1 week ago
qemu-keymap.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] qemu-keymap: fix a small leak
Posted by marcandre.lureau@redhat.com 1 week ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Spotted thanks to ASAN:
Direct leak of 136 byte(s) in 1 object(s) allocated from:
    #0 0x7fd0216f7350 in calloc (/lib64/libasan.so.8+0xf7350) (BuildId: a4ad7eb954b390cf00f07fa10952988a41d9fc7a)
    #1 0x7fd0215d5d5c in xkb_state_new (/lib64/libxkbcommon.so.0+0x1cd5c) (BuildId: 5e4eb795acbf75d373f2930e5d0e84a568225bab)
    #2 0x5593b05bbb5d in main ../qemu-keymap.c:235

SUMMARY: AddressSanitizer: 136 byte(s) leaked in 1 allocation(s).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qemu-keymap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qemu-keymap.c b/qemu-keymap.c
index 701e4332af..603bab4661 100644
--- a/qemu-keymap.c
+++ b/qemu-keymap.c
@@ -261,5 +261,6 @@ int main(int argc, char *argv[])
             "\n"
             "# quirks section end\n");
 
+    xkb_state_unref(state);
     exit(0);
 }
-- 
2.45.2.827.g557ae147e6


Re: [PATCH] qemu-keymap: fix a small leak
Posted by Peter Maydell 1 week ago
On Tue, 1 Oct 2024 at 16:28, <marcandre.lureau@redhat.com> wrote:
>
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Spotted thanks to ASAN:
> Direct leak of 136 byte(s) in 1 object(s) allocated from:
>     #0 0x7fd0216f7350 in calloc (/lib64/libasan.so.8+0xf7350) (BuildId: a4ad7eb954b390cf00f07fa10952988a41d9fc7a)
>     #1 0x7fd0215d5d5c in xkb_state_new (/lib64/libxkbcommon.so.0+0x1cd5c) (BuildId: 5e4eb795acbf75d373f2930e5d0e84a568225bab)
>     #2 0x5593b05bbb5d in main ../qemu-keymap.c:235
>
> SUMMARY: AddressSanitizer: 136 byte(s) leaked in 1 allocation(s).
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  qemu-keymap.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/qemu-keymap.c b/qemu-keymap.c
> index 701e4332af..603bab4661 100644
> --- a/qemu-keymap.c
> +++ b/qemu-keymap.c
> @@ -261,5 +261,6 @@ int main(int argc, char *argv[])
>              "\n"
>              "# quirks section end\n");
>
> +    xkb_state_unref(state);
>      exit(0);
>  }

https://lore.kernel.org/qemu-devel/20240723-unref-v1-1-88606ffd4552@daynix.com/
from July is similar but seems to free slightly more xkb
data structures.

-- PMM