[PATCH v2 1/1] nwfilter: Avoid possible double free in virNWFilterInstReset()

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

 



virNWFilterInstReset() may be called multiple times, leading to a double g_free()
Replace plain g_free() with g_clear_pointer() to prevent this

Found by Linux Verification Center (linuxtesting.org) with Svace.

Reported-by: Dmitry Fedin <d.fedin@xxxxxxxxxxx>
Signed-off-by: Alexander Kuznetsov <kuznetsovam@xxxxxxxxxxxx>
---
 src/nwfilter/nwfilter_gentech_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index f7a909bdc0..7462b84f88 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -203,12 +203,12 @@ virNWFilterInstReset(virNWFilterInst *inst)
 
     for (i = 0; i < inst->nfilters; i++)
         virNWFilterObjUnlock(inst->filters[i]);
-    g_free(inst->filters);
+    g_clear_pointer(inst->filters, g_free);
     inst->nfilters = 0;
 
     for (i = 0; i < inst->nrules; i++)
         virNWFilterRuleInstFree(inst->rules[i]);
-    g_free(inst->rules);
+    g_clear_pointer(inst->rules, g_free);
     inst->nrules = 0;
 }
 
-- 
2.42.4



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux