fd is not close when IOCTL encounters an error which causes resource
leak. The fix is to initialize fd to -1. At return, close fd if
it has a valid value.
Change-Id: I53c4f5c71ca0f556fb6586f5849e7cb622632d8f
Signed-off-by: Steven <sluong@cisco.com>
virtio_main_t *vim = &virtio_main;
vnet_sw_interface_t *sw;
vnet_hw_interface_t *hw;
- int i, fd;
+ int i, fd = -1;
struct ifreq ifr;
size_t hdrsz;
struct vhost_memory *vhost_mem = 0;
_IOCTL (fd, SIOCGIFFLAGS, (void *) &ifr);
ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
_IOCTL (fd, SIOCSIFFLAGS, (void *) &ifr);
- close (fd);
}
if (!args->hw_addr_set)
done:
if (vhost_mem)
clib_mem_free (vhost_mem);
+ if (fd != -1)
+ close (fd);
}
int