All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Yuval Shaia <yuval.shaia@oracle.com>
Subject: Re: [Qemu-devel] [PATCH PULL v2 08/10] hw/rdma: PVRDMA commands and data-path ops
Date: Fri, 27 Apr 2018 21:31:18 +0300	[thread overview]
Message-ID: <7e9f042e-bea2-f855-cb0e-810831449637@redhat.com> (raw)
In-Reply-To: <CAFEAcA8rx712pVT=yn0Xx_CEza2cSNO26F7_RPDudKWi6LnMwA@mail.gmail.com>

On 27/04/2018 18:01, Peter Maydell wrote:
> On 19 February 2018 at 11:43, Marcel Apfelbaum <marcel@redhat.com> wrote:
>> From: Yuval Shaia <yuval.shaia@oracle.com>
>>
>> First PVRDMA sub-module - implementation of the PVRDMA device.
>> - PVRDMA commands such as create CQ and create MR.
>> - Data path QP operations - post_send and post_recv.
>> - Completion handler.
> 
> Coverity CID 1390620: we call munmap() on a NULL pointer.
> 
>> +static int create_mr(PVRDMADev *dev, union pvrdma_cmd_req *req,
>> +                     union pvrdma_cmd_resp *rsp)
>> +{
>> +    struct pvrdma_cmd_create_mr *cmd = &req->create_mr;
>> +    struct pvrdma_cmd_create_mr_resp *resp = &rsp->create_mr_resp;
>> +    PCIDevice *pci_dev = PCI_DEVICE(dev);
>> +    void *host_virt = NULL;
> 
> Here we set host_virt to NULL...
> 
>> +
>> +    memset(resp, 0, sizeof(*resp));
>> +    resp->hdr.response = cmd->hdr.response;
>> +    resp->hdr.ack = PVRDMA_CMD_CREATE_MR_RESP;
>> +
>> +    pr_dbg("pd_handle=%d\n", cmd->pd_handle);
>> +    pr_dbg("access_flags=0x%x\n", cmd->access_flags);
>> +    pr_dbg("flags=0x%x\n", cmd->flags);
>> +
>> +    if (!(cmd->flags & PVRDMA_MR_FLAG_DMA)) {
> 
> ...and if we don't take this if() we won't set host_virt to anything...
> 
>> +        host_virt = pvrdma_map_to_pdir(pci_dev, cmd->pdir_dma, cmd->nchunks,
>> +                                       cmd->length);
>> +        if (!host_virt) {
>> +            pr_dbg("Failed to map to pdir\n");
>> +            resp->hdr.err = -EINVAL;
>> +            goto out;
>> +        }
>> +    }
>> +
>> +    resp->hdr.err = rdma_rm_alloc_mr(&dev->rdma_dev_res, cmd->pd_handle,
>> +                                     cmd->start, cmd->length, host_virt,
>> +                                     cmd->access_flags, &resp->mr_handle,
>> +                                     &resp->lkey, &resp->rkey);
>> +    if (!resp->hdr.err) {
>> +        munmap(host_virt, cmd->length);
> 
> ...but here we call munmap() on it without checking if it is NULL.
> Unlike g_free(), munmap() isn't specified to be "do nothing if
> passed a NULL pointer".

Will fix, thanks for finding it!
Marcel

> 
>> +    }
>> +
>> +out:
>> +    pr_dbg("ret=%d\n", resp->hdr.err);
>> +    return resp->hdr.err;
>> +}
> 
> thanks
> -- PMM
> 

  reply	other threads:[~2018-04-27 18:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-19 11:43 [Qemu-devel] [PATCH PULL v2 00/10] RDMA patches Marcel Apfelbaum
2018-02-19 11:43 ` [Qemu-devel] [PATCH PULL v2 01/10] mem: add share parameter to memory-backend-ram Marcel Apfelbaum
2018-02-19 11:43 ` [Qemu-devel] [PATCH PULL v2 02/10] docs: add pvrdma device documentation Marcel Apfelbaum
2018-02-19 11:43 ` [Qemu-devel] [PATCH PULL v2 03/10] scripts/update-linux-headers: import pvrdma headers Marcel Apfelbaum
2018-02-19 11:43 ` [Qemu-devel] [PATCH PULL v2 04/10] include/standard-headers: add pvrdma related headers Marcel Apfelbaum
2018-02-19 11:43 ` [Qemu-devel] [PATCH PULL v2 05/10] hw/rdma: Add wrappers and macros Marcel Apfelbaum
2018-02-19 11:43 ` [Qemu-devel] [PATCH PULL v2 06/10] hw/rdma: Definitions for rdma device and rdma resource manager Marcel Apfelbaum
2018-02-19 11:43 ` [Qemu-devel] [PATCH PULL v2 07/10] hw/rdma: Implementation of generic rdma device layers Marcel Apfelbaum
2018-02-19 11:43 ` [Qemu-devel] [PATCH PULL v2 08/10] hw/rdma: PVRDMA commands and data-path ops Marcel Apfelbaum
2018-04-27 14:31   ` Peter Maydell
2018-04-27 18:20     ` Marcel Apfelbaum
2018-04-29  7:42       ` Yuval Shaia
2018-04-27 14:43   ` Peter Maydell
2018-04-27 18:22     ` Marcel Apfelbaum
2018-04-27 14:58   ` Peter Maydell
2018-04-27 18:28     ` Marcel Apfelbaum
2018-04-27 15:01   ` Peter Maydell
2018-04-27 18:31     ` Marcel Apfelbaum [this message]
2023-06-20 12:35   ` Peter Maydell
2018-02-19 11:43 ` [Qemu-devel] [PATCH PULL v2 09/10] hw/rdma: Implementation of PVRDMA device Marcel Apfelbaum
2018-04-27 14:49   ` Peter Maydell
2018-04-27 19:36     ` Marcel Apfelbaum
2018-04-29  9:38       ` Yuval Shaia
2018-04-27 14:55   ` Peter Maydell
2018-04-27 19:46     ` Marcel Apfelbaum
2018-04-29  7:18     ` Yuval Shaia
2018-02-19 11:43 ` [Qemu-devel] [PATCH PULL v2 10/10] MAINTAINERS: add entry for hw/rdma Marcel Apfelbaum
2018-02-19 16:43 ` [Qemu-devel] [PATCH PULL v2 00/10] RDMA patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7e9f042e-bea2-f855-cb0e-810831449637@redhat.com \
    --to=marcel@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=yuval.shaia@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.