[1/2] s390: s390_machinemode leak

Message ID 20250122133932.3728429-2-jremus@linux.ibm.com
State Committed
Headers
Series s390: Fix memory leaks in assembler and linker |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Jens Remus Jan. 22, 2025, 1:39 p.m. UTC
  This resolves the following memory leak reported by ASAN:

Direct leak of 17 byte(s) in 1 object(s) allocated from:
    #0 0x3ffb32fbb1d in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x2aa149861cf in xmalloc ../../libiberty/xmalloc.c:149
    #2 0x2aa149868ff in xstrdup ../../libiberty/xstrdup.c:34
    #3 0x2aa1312391f in s390_machinemode ../../gas/config/tc-s390.c:2241
    #4 0x2aa130ddc7b in read_a_source_file ../../gas/read.c:1293
    #5 0x2aa1304f7bf in perform_an_assembly_pass ../../gas/as.c:1223
    #6 0x2aa1304f7bf in main ../../gas/as.c:1436
    #7 0x3ffb282be35 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #8 0x3ffb282bf33 in __libc_start_main_impl ../csu/libc-start.c:360
    #9 0x2aa1305758f  (/home/jremus/git/binutils/build-asan/gas/as-new+0x2d5758f) (BuildId: ...)

gas/
	* config/tc-s390.c (s390_machinemode): Free mode_string before
	returning.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
 gas/config/tc-s390.c | 1 +
 1 file changed, 1 insertion(+)
  

Patch

diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c
index e7a7e7e04f1f..113b9f41a1ec 100644
--- a/gas/config/tc-s390.c
+++ b/gas/config/tc-s390.c
@@ -2287,6 +2287,7 @@  s390_machinemode (int ignore ATTRIBUTE_UNUSED)
 	s390_setup_opcodes ();
     }
 
+  xfree (mode_string);
   demand_empty_rest_of_line ();
 }