aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-12-10 23:54:46 +0100
committerDamjan Marion <damarion@cisco.com>2017-12-10 23:55:47 +0100
commit96504182bb5c62838d31887ce48b837759c76552 (patch)
tree6f061c2d870d18ca814869a9b5242df9c7207d18 /src
parent765b82ba962496fde62c355cd579dfb75f45e093 (diff)
vlib: fix issues in the new pci code reported by coverity
Change-Id: I8acc5c419b6ad01937c3aecec42801463d4a119a Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vlib/linux/pci.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/vlib/linux/pci.c b/src/vlib/linux/pci.c
index 24e2bb594a3..69dcdd0d760 100644
--- a/src/vlib/linux/pci.c
+++ b/src/vlib/linux/pci.c
@@ -259,6 +259,8 @@ vlib_pci_get_device_info (vlib_pci_addr_t * addr, clib_error_t ** error)
}
}
+ close (fd);
+
vec_reset_length (f);
f = format (f, "%v/vpd%c", dev_dir_name, 0);
fd = open ((char *) f, O_RDONLY);
@@ -268,7 +270,7 @@ vlib_pci_get_device_info (vlib_pci_addr_t * addr, clib_error_t ** error)
{
u8 tag[3];
u8 *data = 0;
- int len;
+ uword len;
if (read (fd, &tag, 3) != 3)
break;
@@ -583,8 +585,10 @@ error:
free (s);
if (err)
{
- close (p->config_fd);
- close (p->uio_fd);
+ if (p->config_fd != -1)
+ close (p->config_fd);
+ if (p->uio_fd != -1)
+ close (p->uio_fd);
}
return err;
}
@@ -619,7 +623,7 @@ open_vfio_iommu_group (int group)
s = format (s, "/dev/vfio/%u%c", group, 0);
fd = open ((char *) s, O_RDWR);
if (fd < 0)
- clib_error_return_unix (0, "open '%s'", s);
+ return clib_error_return_unix (0, "open '%s'", s);
group_status.argsz = sizeof (group_status);
if (ioctl (fd, VFIO_GROUP_GET_STATUS, &group_status) < 0)
@@ -779,8 +783,10 @@ error:
vec_free (s);
if (err)
{
- close (dfd);
- close (p->config_fd);
+ if (dfd != -1)
+ close (dfd);
+ if (p->config_fd != -1)
+ close (p->config_fd);
}
return err;
}