util: netdevip: Fix a memleak in virNetDevIPRouteAdd

@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>
This commit is contained in:
Shi Lei 2018-09-07 16:27:39 +08:00 committed by Erik Skultety
parent ca010e9d76
commit f9a59e051c

View 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;