Skip to contentSkip to conversation

Hexagon (disas/hexagon) fix memory leak for early exit

GIT PULL Applied Taylor Simpson 2 participants 5 messages Aug 13, 2021 – Aug 15, 2021

lore
Share & tools
lore
#0 lore raw

The following changes since commit 703e8cd6189cf699c8d5c094bc68b5f3afa6ad71:

Update version for v6.1.0-rc3 release (2021-08-10 19:08:09 +0100)

are available in the git repository at:

https://github.com/quic/qemu tags/pull-hex-20210812

for you to fetch changes up to a7686d5d8528469b596e98eff098a5d3f8328fb3:

Hexagon (disas/hexagon.c) fix memory leak for early exit cases (2021-08-12 09:06:05 -0500)

----------------------------------------------------------------

Don't allocate the string until error conditions have been checked

Fixes a00cfed0e ("Hexagon (disas) disassembler")

Eliminate Coverity CID 1460121 (Resource leak)

----------------------------------------------------------------
Taylor Simpson (1):
Hexagon (disas/hexagon.c) fix memory leak for early exit cases

 disas/hexagon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
#1 lore raw

[PULL 1/1] Hexagon (disas/hexagon.c) fix memory leak for early exit cases

Don't allocate the string until error conditions have been checked

Fixes a00cfed0e ("Hexagon (disas) disassembler")

Eliminate Coverity CID 1460121 (Resource leak)

---
 disas/hexagon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
disas/hexagon.c +2 -1
index 3c24e2a..c1a4ffc 100644
@@ -33,7 +33,7 @@ int print_insn_hexagon(bfd_vma memaddr, struct disassemble_info *info)
 {
     uint32_t words[PACKET_WORDS_MAX];
     bool found_end = false;
-    GString *buf = g_string_sized_new(PACKET_BUFFER_LEN);
+    GString *buf;
     int i, len;
 
     for (i = 0; i < PACKET_WORDS_MAX && !found_end; i++) {
@@ -57,6 +57,7 @@ int print_insn_hexagon(bfd_vma memaddr, struct disassemble_info *info)
         return PACKET_WORDS_MAX * sizeof(uint32_t);
     }
 
+    buf = g_string_sized_new(PACKET_BUFFER_LEN);
     len = disassemble_hexagon(words, i, memaddr, buf);
     (*info->fprintf_func)(info->stream, "%s", buf->str);
     g_string_free(buf, true);
Signature · 1 line
2.7.4
#2 lore raw
In reply to Taylor Simpson
Quoted 11 lines · Taylor Simpson

The following changes since commit 703e8cd6189cf699c8d5c094bc68b5f3afa6ad71:

Update version for v6.1.0-rc3 release (2021-08-10 19:08:09 +0100)

are available in the git repository at:

https://github.com/quic/qemu tags/pull-hex-20210812

for you to fetch changes up to a7686d5d8528469b596e98eff098a5d3f8328fb3:

Quoted 8 lines

Hexagon (disas/hexagon.c) fix memory leak for early exit cases (2021-08-12 09:06:05 -0500)

----------------------------------------------------------------

Don't allocate the string until error conditions have been checked

Fixes a00cfed0e ("Hexagon (disas) disassembler")

Eliminate Coverity CID 1460121 (Resource leak)

I'll put this on my list to apply if we have an rc4, but I don't think this bug is major enough to justify an rc4 if nothing else means we need one.

thanks
-- PMM

#3 lore raw
Quoted 12 lines

-----Original Message-----
From: Peter Maydell <[email protected]>
Sent: Friday, August 13, 2021 3:21 AM
To: Taylor Simpson <[email protected]>
Cc: QEMU Developers <[email protected]>; Richard Henderson <[email protected]>; Philippe Mathieu-Daudé <[email protected]>
Subject: Re: [PULL 0/1] Hexagon (disas/hexagon) fix memory leak for early exit

Quoted 2 lines

I'll put this on my list to apply if we have an rc4, but I don't think this bug is major enough to justify an rc4 if nothing else means we need one.

Agreed. Thanks Peter!

Taylor

#4 lore raw
In reply to Taylor Simpson
Quoted 15 lines · Taylor Simpson

The following changes since commit 703e8cd6189cf699c8d5c094bc68b5f3afa6ad71:

Update version for v6.1.0-rc3 release (2021-08-10 19:08:09 +0100)

are available in the git repository at:

https://github.com/quic/qemu tags/pull-hex-20210812

for you to fetch changes up to a7686d5d8528469b596e98eff098a5d3f8328fb3:

Hexagon (disas/hexagon.c) fix memory leak for early exit cases (2021-08-12 09:06:05 -0500)

----------------------------------------------------------------

Quoted 8 lines

Don't allocate the string until error conditions have been checked

Fixes a00cfed0e ("Hexagon (disas) disassembler")

Eliminate Coverity CID 1460121 (Resource leak)

----------------------------------------------------------------
Taylor Simpson (1):
Hexagon (disas/hexagon.c) fix memory leak for early exit cases

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/6.1
for any user-visible changes.

-- PMM