diff options
author | Mohsin Kazmi <sykazmi@cisco.com> | 2020-08-20 17:18:56 +0200 |
---|---|---|
committer | BenoƮt Ganne <bganne@cisco.com> | 2020-08-31 09:05:02 +0000 |
commit | 133c91c1c06e7c773ba675181901ba0dcf955ae6 (patch) | |
tree | 83000f26d297fde5ba53d0916b7b57ca9446a770 /src/vnet/devices/virtio/pci.c | |
parent | 2b79341dcafe8fa9397acf42b8021c88664db2df (diff) |
virtio: fix the coverity warning
Type: fix
Change-Id: I6c6d66ad8aa158be8d2b9d111de7d46473b9dc02
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vnet/devices/virtio/pci.c')
-rw-r--r-- | src/vnet/devices/virtio/pci.c | 9 |
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) { |