Skip to content

Commit 28c16b7

Browse files
QiangWei Zhangzippy2
authored andcommitted
virnetdevtap: Fix memory leak in virNetDevTapReattachBridge
Variable 'master' needs to be free because it will be reassigned in virNetDevOpenvswitchInterfaceGetMaster(). The leaked stack: Direct leak of 11 byte(s) in 1 object(s) allocated from: #0 0x7f7dad8ba6df in __interceptor_malloc (/lib64/libasan.so.8+0xba6df) #1 0x7f7dad715728 in g_malloc (/lib64/libglib-2.0.so.0+0x60728) #2 0x7f7dad72d8b2 in g_strdup (/lib64/libglib-2.0.so.0+0x788b2) #3 0x7f7dacb63088 in g_strdup_inline /usr/include/glib-2.0/glib/gstrfuncs.h:321 #4 0x7f7dacb63088 in virNetDevGetName ../src/util/virnetdev.c:823 #5 0x7f7dacb63886 in virNetDevGetMaster ../src/util/virnetdev.c:909 #6 0x7f7dacb90288 in virNetDevTapReattachBridge ../src/util/virnetdevtap.c:527 #7 0x7f7dacd5cd67 in virDomainNetNotifyActualDevice ../src/conf/domain_conf.c:30505 #8 0x7f7da3a10bc3 in qemuProcessNotifyNets ../src/qemu/qemu_process.c:3290 #9 0x7f7da3a375c6 in qemuProcessReconnect ../src/qemu/qemu_process.c:9211 #10 0x7f7dacc0cc53 in virThreadHelper ../src/util/virthread.c:256 #11 0x7f7dac2875d4 in start_thread (/lib64/libc.so.6+0x875d4) #12 0x7f7dac3091bb in __GI___clone3 (/lib64/libc.so.6+0x1091bb) Fixes: de938b9 Signed-off-by: QiangWei Zhang <[email protected]> Reviewed-by: Peter Krempa <[email protected]>
1 parent 6c4260b commit 28c16b7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/util/virnetdevtap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ virNetDevTapReattachBridge(const char *tapname,
541541
/* IFLA_MASTER for a tap on an OVS switch is always "ovs-system" */
542542
if (STREQ_NULLABLE(master, "ovs-system")) {
543543
useOVS = true;
544+
545+
/* master needs to be released here because it will be reassigned */
546+
g_clear_pointer(&master, g_free);
544547
if (virNetDevOpenvswitchInterfaceGetMaster(tapname, &master) < 0)
545548
return -1;
546549
}

0 commit comments

Comments
 (0)