Remove redundant NULL pointer checks before free functions found by nullfree.cocci
Signed-off-by: Stephen Hemminger <step...@networkplumber.org> Reviewed-by: Chenbo Xia <chenbo....@intel.com> --- lib/vhost/iotlb.c | 3 +-- lib/vhost/vhost_crypto.c | 6 ++---- lib/vhost/vhost_user.c | 9 +++------ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/vhost/iotlb.c b/lib/vhost/iotlb.c index b24202a7eba3..5a5ba8b82a61 100644 --- a/lib/vhost/iotlb.c +++ b/lib/vhost/iotlb.c @@ -324,8 +324,7 @@ vhost_user_iotlb_init(struct virtio_net *dev, int vq_index) /* If already created, free it and recreate */ vq->iotlb_pool = rte_mempool_lookup(pool_name); - if (vq->iotlb_pool) - rte_mempool_free(vq->iotlb_pool); + rte_mempool_free(vq->iotlb_pool); vq->iotlb_pool = rte_mempool_create(pool_name, IOTLB_CACHE_SIZE, sizeof(struct vhost_iotlb_entry), 0, diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c index 926b5c0bd94a..012e0cefdeba 100644 --- a/lib/vhost/vhost_crypto.c +++ b/lib/vhost/vhost_crypto.c @@ -1498,10 +1498,8 @@ rte_vhost_crypto_create(int vid, uint8_t cryptodev_id, return 0; error_exit: - if (vcrypto->session_map) - rte_hash_free(vcrypto->session_map); - if (vcrypto->mbuf_pool) - rte_mempool_free(vcrypto->mbuf_pool); + rte_hash_free(vcrypto->session_map); + rte_mempool_free(vcrypto->mbuf_pool); rte_free(vcrypto); diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index e8297a09eb73..b50e5ab5a9c4 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -488,8 +488,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev, } if (vq_is_packed(dev)) { - if (vq->shadow_used_packed) - rte_free(vq->shadow_used_packed); + rte_free(vq->shadow_used_packed); vq->shadow_used_packed = rte_malloc_socket(NULL, vq->size * sizeof(struct vring_used_elem_packed), @@ -502,8 +501,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev, } } else { - if (vq->shadow_used_split) - rte_free(vq->shadow_used_split); + rte_free(vq->shadow_used_split); vq->shadow_used_split = rte_malloc_socket(NULL, vq->size * sizeof(struct vring_used_elem), @@ -517,8 +515,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev, } } - if (vq->batch_copy_elems) - rte_free(vq->batch_copy_elems); + rte_free(vq->batch_copy_elems); vq->batch_copy_elems = rte_malloc_socket(NULL, vq->size * sizeof(struct batch_copy_elem), RTE_CACHE_LINE_SIZE, vq->numa_node); -- 2.34.1