Skip to contentSkip to conversation

hw/pvrdma: Check the correct return value

PATCH In review Yuval Shaia 2 participants 2 messages Oct 25, 2018 – Oct 29, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/pvrdma: Check the correct return value

Return value of 0 means ok, we want to free the memory only in case of error.

---
 hw/rdma/vmw/pvrdma_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/rdma/vmw/pvrdma_cmd.c +1 -1
index 4faeb21631..57d6f41ae6 100644
@@ -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);
     }
 
Signature · 1 line
2.17.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Yuval Shaia

Return value of 0 means ok, we want to free the memory only in case of error.

---
  hw/rdma/vmw/pvrdma_cmd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
hw/rdma/vmw/pvrdma_cmd.c +0 -0
index 4faeb21631..57d6f41ae6 100644

hw/rdma/vmw/pvrdma_cmd.c static int create_mr(PVRDMADev *dev, union pvrdma_cmd_req *req, · line 238

Quoted 8 lines
hw/rdma/vmw/pvrdma_cmd.c +1 -1
@@ -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);
      }
 

Thanks,
Marcel