From: Marcel Apfelbaum Date: Mon, 30 Apr 2018 20:02:17 +0000 (+0300) Subject: hw/rdma: Fix possible munmap call on a NULL pointer X-Git-Tag: v3.0.0-rc0~181^2~7 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=1bad4957c8c4d5367961cb3d5287b2f25a1d6847;p=users%2Fdwmw2%2Fqemu.git hw/rdma: Fix possible munmap call on a NULL pointer Coverity CID 1390620: we call munmap() on a NULL pointer. Reported-by: Peter Maydell Signed-off-by: Marcel Apfelbaum Reviewed-by: Yuval Shaia Message-Id: <20180430200223.4119-2-marcel.apfelbaum@gmail.com> --- diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c index 99019d8741..f9dd78cb27 100644 --- a/hw/rdma/vmw/pvrdma_cmd.c +++ b/hw/rdma/vmw/pvrdma_cmd.c @@ -232,7 +232,7 @@ static int create_mr(PVRDMADev *dev, union pvrdma_cmd_req *req, cmd->start, cmd->length, host_virt, cmd->access_flags, &resp->mr_handle, &resp->lkey, &resp->rkey); - if (!resp->hdr.err) { + if (host_virt && !resp->hdr.err) { munmap(host_virt, cmd->length); }