From a086e304e4061569c0cb1cfb20a5c045c0e92c16 Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Fri, 4 Oct 2019 17:30:21 +0200 Subject: vlib: pci: set pci driver name to none when no driver is loaded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If no Linux PCI driver module is loaded, then the driver_name in the PCI info struct is NULL. This can triggers crash when checking driver name eg. in vlib_pci_device_open(). Default to "" as driver name, which should never match. Type: fix Change-Id: I9e69889a7566467bd8220b92bbbaa72ada957257 Signed-off-by: Benoît Ganne (cherry picked from commit 0eae2bb1f1199f7dcb6a8c62b1ea612ed9ee4ae1) --- src/vlib/linux/pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vlib/linux/pci.c b/src/vlib/linux/pci.c index fdb5271f56a..82f5007818e 100644 --- a/src/vlib/linux/pci.c +++ b/src/vlib/linux/pci.c @@ -291,6 +291,8 @@ vlib_pci_get_device_info (vlib_main_t * vm, vlib_pci_addr_t * addr, vec_reset_length (f); f = format (f, "%v/driver%c", dev_dir_name, 0); di->driver_name = clib_sysfs_link_to_name ((char *) f); + if (!di->driver_name) + di->driver_name = format (0, "%c", 0); di->iommu_group = -1; if (lvm->container_fd != -1) -- cgit 1.2.3-korg