diff mbox series

[ibsim,21/23] sim_net.c: Free pattern buffer

Message ID 20190102131318.5765-21-honli@redhat.com (mailing list archive)
State Not Applicable
Headers show
Series [ibsim,01/23] move sim_cmd_file into ibsim/sim_cmd.c | expand

Commit Message

Honggang LI Jan. 2, 2019, 1:13 p.m. UTC
==11591== 9,824 (1,792 direct, 8,032 indirect) bytes in 8 blocks are definitely lost in loss record 36 of 36
==11591==    at 0x4C2ED48: malloc (vg_replace_malloc.c:298)
==11591==    by 0x4C31363: realloc (vg_replace_malloc.c:826)
==11591==    by 0x533D25C: re_compile_internal (in /usr/lib64/libc-2.27.so)
==11591==    by 0x533DC3B: regcomp (in /usr/lib64/libc-2.27.so)
==11591==    by 0x402BEB: parse_port_connection_data (sim_net.c:531)
==11591==    by 0x403CBF: parse_port (sim_net.c:815)
==11591==    by 0x403DF7: parse_ports (sim_net.c:842)
==11591==    by 0x404021: parse_switch (sim_net.c:904)
==11591==    by 0x4049CB: parse_netconf (sim_net.c:1111)
==11591==    by 0x404F1F: read_netconf (sim_net.c:1166)
==11591==    by 0x4126D4: sim_init_net (ibsim.c:523)
==11591==    by 0x413445: main (ibsim.c:777)

Signed-off-by: Honggang Li <honli@redhat.com>
---
 ibsim/sim_net.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Hal Rosenstock Jan. 4, 2019, 12:50 p.m. UTC | #1
On 1/2/2019 8:13 AM, Honggang Li wrote:
> ==11591== 9,824 (1,792 direct, 8,032 indirect) bytes in 8 blocks are definitely lost in loss record 36 of 36
> ==11591==    at 0x4C2ED48: malloc (vg_replace_malloc.c:298)
> ==11591==    by 0x4C31363: realloc (vg_replace_malloc.c:826)
> ==11591==    by 0x533D25C: re_compile_internal (in /usr/lib64/libc-2.27.so)
> ==11591==    by 0x533DC3B: regcomp (in /usr/lib64/libc-2.27.so)
> ==11591==    by 0x402BEB: parse_port_connection_data (sim_net.c:531)
> ==11591==    by 0x403CBF: parse_port (sim_net.c:815)
> ==11591==    by 0x403DF7: parse_ports (sim_net.c:842)
> ==11591==    by 0x404021: parse_switch (sim_net.c:904)
> ==11591==    by 0x4049CB: parse_netconf (sim_net.c:1111)
> ==11591==    by 0x404F1F: read_netconf (sim_net.c:1166)
> ==11591==    by 0x4126D4: sim_init_net (ibsim.c:523)
> ==11591==    by 0x413445: main (ibsim.c:777)
> 
> Signed-off-by: Honggang Li <honli@redhat.com>

Thanks. Applied.

-- Hal
diff mbox series

Patch

diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c
index bdce93a6ac10..068c38ef9f52 100644
--- a/ibsim/sim_net.c
+++ b/ibsim/sim_net.c
@@ -533,6 +533,7 @@  static int parse_port_connection_data(Port * port, int type, char *line)
 
 	if (rc) {
 		IBWARN("cannot parse remote lid and connection type");
+		regfree(&regex);
 		return 0;
 	}
 
@@ -542,18 +543,23 @@  static int parse_port_connection_data(Port * port, int type, char *line)
 		/* expecting line with the following format:
 		 * [1]	"H-000123456789ABCD"[2](123456789ABCE) 		# "description" lid 1 4xQDR ...
 		 */
-		if (parse_port_link_width_and_speed(port, line_connection_type))
+		if (parse_port_link_width_and_speed(port, line_connection_type)) {
+			regfree(&regex);
 			return -1;
+		}
 	}
 	if (type == HCA_NODE) {
 		/* expecting line with the following format:
 		 * [1](123456789ABCDE) 	"S-000123456789ABCDF"[2]		# lid 2 lmc 0 "description" lid 1 4xQDR ...
 		 */
 		if (parse_port_lid_and_lmc(port, line) ||
-		    parse_port_link_width_and_speed(port, line_connection_type))
+		    parse_port_link_width_and_speed(port, line_connection_type)) {
+			regfree(&regex);
 			return -1;
+		}
 	}
 
+	regfree(&regex);
 	return 0;
 }