summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2022-12-19 18:23:03 +0100
committerDave Wallace <dwallacelf@gmail.com>2023-01-18 00:38:09 +0000
commitcc16e7bad74c18b1a682329af5e760c4cd8381ea (patch)
tree7fc9602778155e7b851119a53833c112bf50d4e5
parenta35f56663fe6dde5da13fd52fa50a28080f6dd2f (diff)
pci: fix musl crash
The musl libc does not support closedir(0) resulting in a crash. Only call closedir() if we successfully opened it. Type: fix Change-Id: I3198454f44735501047afc42b94b2fea273212f4 Signed-off-by: Benoît Ganne <bganne@cisco.com>
-rw-r--r--src/vlib/linux/pci.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/vlib/linux/pci.c b/src/vlib/linux/pci.c
index 83e9dde2f16..75d9edf8849 100644
--- a/src/vlib/linux/pci.c
+++ b/src/vlib/linux/pci.c
@@ -486,7 +486,7 @@ vlib_pci_bind_to_uio (vlib_main_t *vm, vlib_pci_addr_t *addr,
"is bound to IOMMU group and "
"vfio-pci driver is not loaded",
format_vlib_pci_addr, addr);
- goto done;
+ goto err0;
}
else
uio_drv_name = "vfio-pci";
@@ -507,7 +507,7 @@ vlib_pci_bind_to_uio (vlib_main_t *vm, vlib_pci_addr_t *addr,
error = clib_error_return (0, "Skipping PCI device %U: missing "
"kernel VFIO or UIO driver",
format_vlib_pci_addr, addr);
- goto done;
+ goto err0;
}
clib_error_free (error);
}
@@ -521,7 +521,7 @@ vlib_pci_bind_to_uio (vlib_main_t *vm, vlib_pci_addr_t *addr,
((strcmp ("vfio-pci", (char *) driver_name) == 0) ||
(strcmp ("uio_pci_generic", (char *) driver_name) == 0) ||
(strcmp ("igb_uio", (char *) driver_name) == 0)))
- goto done;
+ goto err0;
if (!force)
{
@@ -536,14 +536,14 @@ vlib_pci_bind_to_uio (vlib_main_t *vm, vlib_pci_addr_t *addr,
"Skipping PCI device %U: failed to "
"read /sys/class/net",
format_vlib_pci_addr, addr);
- goto done;
+ goto err0;
}
fd = socket (PF_INET, SOCK_DGRAM, 0);
if (fd < 0)
{
error = clib_error_return_unix (0, "socket");
- goto done;
+ goto err1;
}
while ((e = readdir (dir)))
@@ -580,7 +580,7 @@ vlib_pci_bind_to_uio (vlib_main_t *vm, vlib_pci_addr_t *addr,
error = clib_error_return_unix (0, "ioctl fetch intf %s flags",
e->d_name);
close (fd);
- goto done;
+ goto err1;
}
if (ifr.ifr_flags & IFF_UP)
@@ -590,7 +590,7 @@ vlib_pci_bind_to_uio (vlib_main_t *vm, vlib_pci_addr_t *addr,
"interface %s is up",
format_vlib_pci_addr, addr, e->d_name);
close (fd);
- goto done;
+ goto err1;
}
}
@@ -628,8 +628,9 @@ vlib_pci_bind_to_uio (vlib_main_t *vm, vlib_pci_addr_t *addr,
vec_reset_length (s);
}
-done:
+err1:
closedir (dir);
+err0:
vec_free (s);
vec_free (dev_dir_name);
vec_free (driver_name);