From: Yuanhan Liu Date: Tue, 5 Apr 2016 06:00:43 +0000 (+0800) Subject: vhost: fix error handling in destroy X-Git-Tag: spdx-start~7073 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=71dc571efd0a930ebb7334260059e87711fdfc27;p=dpdk.git vhost: fix error handling in destroy Fix following coverity defect: 291 void 292 vhost_destroy_device(struct vhost_device_ctx ctx) 293 { 294 struct virtio_net *dev = get_device(ctx); 295 >>> CID 124565: Null pointer dereferences (NULL_RETURNS) >>> Dereferencing a null pointer "dev". Fixes: 45ca9c6f7bc6 ("vhost: get rid of linked list for devices") Reported-by: John McNamara Signed-off-by: Yuanhan Liu --- diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index 90da9bafda..d870ad97ab 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -293,6 +293,9 @@ vhost_destroy_device(struct vhost_device_ctx ctx) { struct virtio_net *dev = get_device(ctx); + if (dev == NULL) + return; + if (dev->flags & VIRTIO_DEV_RUNNING) notify_ops->destroy_device(dev);