From 5dedae7291236a399a234ac6fa86f16d9030a0d6 Mon Sep 17 00:00:00 2001 From: Steven Luong Date: Wed, 31 Jul 2019 16:01:14 -0700 Subject: 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 Change-Id: I0626115f4951a88f23d9792f0232fb57c132fbc2 --- src/vnet/devices/virtio/vhost_user_input.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/vnet/devices') 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); } -- cgit 1.2.3-korg