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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



==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@xxxxxxxxxx>
---
 ibsim/sim_net.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

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;
 }
 
-- 
2.15.0-rc1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux