diff mbox series

hw/pvrdma: Check the correct return value

Message ID 20181025061700.17050-1-yuval.shaia@oracle.com
State New
Headers show
Series hw/pvrdma: Check the correct return value | expand

Commit Message

Yuval Shaia Oct. 25, 2018, 6:17 a.m. UTC
Return value of 0 means ok, we want to free the memory only in case of
error.

Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
---
 hw/rdma/vmw/pvrdma_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marcel Apfelbaum Oct. 29, 2018, 8:57 a.m. UTC | #1
On 10/25/18 9:17 AM, Yuval Shaia wrote:
> Return value of 0 means ok, we want to free the memory only in case of
> error.
>
> Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
> ---
>   hw/rdma/vmw/pvrdma_cmd.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c
> index 4faeb21631..57d6f41ae6 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 (host_virt && !resp->hdr.err) {
> +    if (resp->hdr.err && host_virt) {
>           munmap(host_virt, cmd->length);
>       }
>   

Reviewed-by: Marcel Apfelbaum<marcel.apfelbaum@gmail.com>

Thanks,
Marcel
diff mbox series

Patch

diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c
index 4faeb21631..57d6f41ae6 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 (host_virt && !resp->hdr.err) {
+    if (resp->hdr.err && host_virt) {
         munmap(host_virt, cmd->length);
     }