From 969493f91d107767d827feaa55908cd4c1bf5a2f Mon Sep 17 00:00:00 2001 From: Nehal J Wani Date: Sun, 23 Feb 2014 01:30:53 +0530 Subject: [PATCH] Fix memory leak in virSCSIDeviceListDel() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While running virscsitest, it was found that valgrind pointed out the following memory leak: ==320== 5 bytes in 1 blocks are definitely lost in loss record 4 of 37 ==320== at 0x4A069EE: malloc (vg_replace_malloc.c:270) ==320== by 0x3E6CE81171: strdup (strdup.c:43) ==320== by 0x4CB28DF: virStrdup (virstring.c:554) ==320== by 0x4CAC987: virSCSIDeviceSetUsedBy (virscsi.c:289) ==320== by 0x402321: test2 (virscsitest.c:100) ==320== by 0x403231: virtTestRun (testutils.c:199) ==320== by 0x402121: mymain (virscsitest.c:180) ==320== by 0x4039AD: virtTestMain (testutils.c:782) ==320== by 0x3E6CE1ED1C: (below main) (libc-start.c:226) ==320== Introduced by commit fd243fc. Signed-off-by: Ján Tomko --- src/util/virscsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/virscsi.c b/src/util/virscsi.c index acc3815989..2f469f2b45 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -435,6 +435,7 @@ virSCSIDeviceListDel(virSCSIDeviceListPtr list, for (i = 0; i < dev->n_used_by; i++) { if (STREQ_NULLABLE(dev->used_by[i], name)) { if (dev->n_used_by > 1) { + VIR_FREE(dev->used_by[i]); VIR_DELETE_ELEMENT(dev->used_by, i, dev->n_used_by); } else { tmp = virSCSIDeviceListSteal(list, dev);