From: Huawei Xie Date: Mon, 13 Jun 2016 14:53:08 +0000 (+0800) Subject: net/virtio: fix crash when no devargs X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7e40200c567ff798d7cd54085c3744cf3393ce66;p=dpdk.git net/virtio: fix crash when no devargs We skip kernel managed virtio devices, if it isn't whitelisted. Before checking if the virtio device is whitelisted, check if devargs is specified. Fixes: ac5e1d838dc1 ("virtio: skip error when probing kernel managed device") Reported-by: Vincent Li Signed-off-by: Huawei Xie Acked-by: Yuanhan Liu --- diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index 941081d3fa..7790707922 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -694,6 +694,7 @@ next: * Return -1: * if there is error mapping with VFIO/UIO. * if port map error when driver type is KDRV_NONE. + * if whitelisted but driver type is KDRV_UNKNOWN. * Return 1 if kernel driver is managing the device. * Return 0 on success. */ @@ -719,7 +720,8 @@ vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw, PMD_INIT_LOG(INFO, "trying with legacy virtio pci."); if (legacy_virtio_resource_init(dev, hw, dev_flags) < 0) { if (dev->kdrv == RTE_KDRV_UNKNOWN && - dev->devargs->type != RTE_DEVTYPE_WHITELISTED_PCI) { + (!dev->devargs || + dev->devargs->type != RTE_DEVTYPE_WHITELISTED_PCI)) { PMD_INIT_LOG(INFO, "skip kernel managed virtio device."); return 1;