diff options
author | Steven <sluong@cisco.com> | 2017-11-30 16:56:54 -0800 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-12-01 11:14:52 +0000 |
commit | f953dfc8e01426ce93588e9013c112e48a9a8463 (patch) | |
tree | dd5e7eb09511df669dc9bec6a1cbf0300df3c344 /src/vnet/devices/netlink.c | |
parent | 088f0e221c05b7b1cd59b61442eaf595e22e2fef (diff) |
virtio: fix coverity warnings
Fix 3 coverity warnings
1. api_format.c: init net_ns = 0 and remove its corresponding vec_add and
vec_free
2. netlink.c (reported in tap.c before the code was removed): resource leaked
due to fd is not close
3. tap.c: subtract 1 for size when calling strncpy to accommodate the
terminated NULL character
Change-Id: Iff4e66604862f0c06dac227b8cfd48d3979e41a5
Signed-off-by: Steven <sluong@cisco.com>
Diffstat (limited to 'src/vnet/devices/netlink.c')
-rw-r--r-- | src/vnet/devices/netlink.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/vnet/devices/netlink.c b/src/vnet/devices/netlink.c index b2a651348a3..b05daf2674a 100644 --- a/src/vnet/devices/netlink.c +++ b/src/vnet/devices/netlink.c @@ -48,16 +48,16 @@ vnet_netlink_set_if_attr (int ifindex, unsigned short rta_type, void *data, memset (&req, 0, sizeof (req)); if ((sock = socket (AF_NETLINK, SOCK_RAW, NETLINK_ROUTE)) == -1) - { - err = clib_error_return_unix (0, "socket(AF_NETLINK)"); - goto error; - } + return clib_error_return_unix (0, "socket(AF_NETLINK)"); ra.nl_family = AF_NETLINK; ra.nl_pid = getpid (); if ((bind (sock, (struct sockaddr *) &ra, sizeof (ra))) == -1) - return clib_error_return_unix (0, "bind"); + { + err = clib_error_return_unix (0, "bind"); + goto error; + } req.nh.nlmsg_len = NLMSG_LENGTH (sizeof (struct ifinfomsg)); req.nh.nlmsg_flags = NLM_F_REQUEST; @@ -75,6 +75,7 @@ vnet_netlink_set_if_attr (int ifindex, unsigned short rta_type, void *data, err = clib_error_return_unix (0, "send"); error: + close (sock); return err; } |