From a1aa88b7dcac2b22d74908f9276d5d145d8e65a0 Mon Sep 17 00:00:00 2001 From: Yuval Shaia Date: Wed, 16 Jan 2019 17:15:38 +0200 Subject: hw/rdma: Verify that ptr is not NULL before freeing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To cover the case where fini() was called even when init() fails make sure objects are not NULL before calling to non-null-safe destructors. Signed-off-by: Yuval Shaia Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20190116151538.14088-1-yuval.shaia@oracle.com> Signed-off-by: Marcel Apfelbaum --- hw/rdma/rdma_backend.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'hw/rdma/rdma_backend.c') diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c index b49edaacaf..3ee5172c96 100644 --- a/hw/rdma/rdma_backend.c +++ b/hw/rdma/rdma_backend.c @@ -1066,8 +1066,10 @@ static void mad_fini(RdmaBackendDev *backend_dev) pr_dbg("Stopping MAD\n"); disable_rdmacm_mux_async(backend_dev); qemu_chr_fe_disconnect(backend_dev->rdmacm_mux.chr_be); - qlist_destroy_obj(QOBJECT(backend_dev->recv_mads_list.list)); - qemu_mutex_destroy(&backend_dev->recv_mads_list.lock); + if (backend_dev->recv_mads_list.list) { + qlist_destroy_obj(QOBJECT(backend_dev->recv_mads_list.list)); + qemu_mutex_destroy(&backend_dev->recv_mads_list.lock); + } } int rdma_backend_get_gid_index(RdmaBackendDev *backend_dev, -- cgit v1.2.3