aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/virtio
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2019-07-31 16:01:14 -0700
committerDave Barach <openvpp@barachs.net>2019-08-02 20:32:14 +0000
commit5dedae7291236a399a234ac6fa86f16d9030a0d6 (patch)
tree3029984a5cddc1511915a858796bcbb3ddcc7a61 /src/vnet/devices/virtio
parentd2c9e702098a4fcc45310d59e18bffc9626d3849 (diff)
devices: add null check after map_guest_mem calls
map_guest_mem may return null. Coverity complains about calls without checking its return. Simple stuff. Type: fix Signed-off-by: Steven Luong <sluong@cisco.com> Change-Id: I0626115f4951a88f23d9792f0232fb57c132fbc2
Diffstat (limited to 'src/vnet/devices/virtio')
-rw-r--r--src/vnet/devices/virtio/vhost_user_input.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/vnet/devices/virtio/vhost_user_input.c b/src/vnet/devices/virtio/vhost_user_input.c
index 22f79e60555..488764ba0b7 100644
--- a/src/vnet/devices/virtio/vhost_user_input.c
+++ b/src/vnet/devices/virtio/vhost_user_input.c
@@ -585,10 +585,24 @@ vhost_user_if_input (vlib_main_t * vm,
data_offset = 0;
}
hdr = map_guest_mem (vui, desc_table[current].addr, &map_hint);
+ if (PREDICT_FALSE (hdr == 0))
+ {
+ vlib_error_count (vm, node->node_index,
+ VHOST_USER_INPUT_FUNC_ERROR_MMAP_FAIL, 1);
+ goto out;
+ }
b_data = (u8 *) hdr + data_offset;
if (indirect)
- hdr = map_guest_mem (vui, desc_table[desc_current].addr,
- &map_hint);
+ {
+ hdr = map_guest_mem (vui, desc_table[desc_current].addr,
+ &map_hint);
+ if (PREDICT_FALSE (hdr == 0))
+ {
+ vlib_error_count (vm, node->node_index,
+ VHOST_USER_INPUT_FUNC_ERROR_MMAP_FAIL, 1);
+ goto out;
+ }
+ }
vhost_user_handle_rx_offload (b_head, b_data, &hdr->hdr);
}