]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: netdevip: Fix a memleak in virNetDevIPRouteAdd
authorShi Lei <shi_lei@massclouds.com>
Fri, 7 Sep 2018 08:27:39 +0000 (16:27 +0800)
committerErik Skultety <eskultet@redhat.com>
Fri, 7 Sep 2018 11:33:57 +0000 (13:33 +0200)
@resp is allocated by virNetlinkCommand and the caller is responsible
for freeing the buffer. Since we already converted this module to use
VIR_AUTO{FREE,PTR} macros, let's resolve the problem by using them.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/util/virnetdevip.c

index 0f080a577d4206a41a5de6136bfe8d777f8151b6..103ff9edcbc34450bc7fff271eda87688a733e83 100644 (file)
@@ -283,7 +283,6 @@ virNetDevIPRouteAdd(const char *ifname,
                     virSocketAddrPtr gateway,
                     unsigned int metric)
 {
-    struct nlmsghdr *resp = NULL;
     unsigned int recvbuflen;
     unsigned int ifindex;
     struct rtmsg rtmsg;
@@ -296,6 +295,7 @@ virNetDevIPRouteAdd(const char *ifname,
     VIR_AUTOPTR(virNetlinkMsg) nlmsg = NULL;
     VIR_AUTOFREE(char *) toStr = NULL;
     VIR_AUTOFREE(char *) viaStr = NULL;
+    VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
 
     actualAddr = addr;