aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/virtio/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/devices/virtio/pci.c')
-rw-r--r--src/vnet/devices/virtio/pci.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/vnet/devices/virtio/pci.c b/src/vnet/devices/virtio/pci.c
index 494a3f383fa..1e94bbdc029 100644
--- a/src/vnet/devices/virtio/pci.c
+++ b/src/vnet/devices/virtio/pci.c
@@ -727,8 +727,13 @@ 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);
- vif->bar = bar[cap.bar];
- vif->bar_id = cap.bar;
+ if (cap.bar >= 1 && cap.bar <= 5)
+ {
+ vif->bar = bar[cap.bar];
+ vif->bar_id = cap.bar;
+ }
+ else
+ return clib_error_return (error, "invalid bar %u", cap.bar);
switch (cap.cfg_type)
{