virtio: fix the bar starting index
[vpp.git] / src / vnet / devices / virtio / pci.c
index 4877117..6c6edbc 100644 (file)
@@ -729,7 +729,7 @@ virtio_pci_read_caps (vlib_main_t * vm, virtio_if_t * vif, void **bar)
                        "[%4x] cfg type: %u, bar: %u, offset: %04x, len: %u",
                        pos, cap.cfg_type, cap.bar, cap.offset, cap.length);
 
-      if (cap.bar >= 1 && cap.bar <= 5)
+      if (cap.bar >= 0 && cap.bar <= 5)
        {
          vif->bar = bar[cap.bar];
          vif->bar_id = cap.bar;
@@ -1219,7 +1219,8 @@ virtio_pci_delete_if (vlib_main_t * vm, virtio_if_t * vif)
   if (vif->features & VIRTIO_FEATURE (VIRTIO_NET_F_CTRL_VQ))
     vif->virtio_pci_func->del_queue (vm, vif, vif->max_queue_pairs * 2);
 
-  vif->virtio_pci_func->device_reset (vm, vif);
+  if (vif->virtio_pci_func)
+    vif->virtio_pci_func->device_reset (vm, vif);
 
   if (vif->hw_if_index)
     {