hw: pvrdma: fix memory leak in error path
PATCH 1/1 hw: pvrdma: fix memory leak in error path
Spotted by Coverity: CID 1398595
--- hw/rdma/vmw/pvrdma_qp_ops.c | 2 ++ 1 file changed, 2 insertions(+)
hw/rdma/vmw/pvrdma_qp_ops.c +2 -0
@@ -168,6 +168,7 @@ int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle) sgid =rdma_rm_get_gid (&dev->rdma_dev_res, wqe->hdr.wr.ud.av.gid_index);if (!sgid) {pr_dbg ("Fail to get gid for idx %d\n" , wqe->hdr.wr.ud.av.gid_index); +g_free (comp_ctx);return -EIO ; } pr_dbg("sgid_id=%d, sgid=0x%llx\n", wqe->hdr.wr.ud.av.gid_index,
@@ -179,6 +180,7 @@ int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle)if (sgid_idx <=0 ) {pr_dbg ("Fail to get bk sgid_idx for sgid_idx %d\n" , wqe->hdr.wr.ud.av.gid_index); +g_free (comp_ctx);return -EIO ; }
Signature · 1 line
2.17.1
Quoted 2 lines · Li Qiang
Spotted by Coverity: CID 1398595
Quoted 1 line
Signed-off-by Li Qiang <[email protected]>
Quoted 25 lines
--- hw/rdma/vmw/pvrdma_qp_ops.c | 2 ++ 1 file changed, 2 insertions(+)hw/rdma/vmw/pvrdma_qp_ops.c +2
-0@@ -168,6 +168,7 @@ int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle) sgid =rdma_rm_get_gid (&dev->rdma_dev_res, wqe->hdr.wr.ud.av.gid_index);if (!sgid) {pr_dbg ("Fail to get gid for idx %d\n" , wqe->hdr.wr.ud.av.gid_index); +g_free (comp_ctx);return -EIO ; } pr_dbg("sgid_id=%d, sgid=0x%llx\n", wqe->hdr.wr.ud.av.gid_index,@@ -179,6 +180,7 @@ int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle)if (sgid_idx <=0 ) {pr_dbg ("Fail to get bk sgid_idx for sgid_idx %d\n" , wqe->hdr.wr.ud.av.gid_index); +g_free (comp_ctx);return -EIO ; }
Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Li Qiang
Spotted by Coverity: CID 1398595
Fixes 2b05705dc8Quoted 1 line
Signed-off-by Li Qiang <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Quoted 15 lines
--- hw/rdma/vmw/pvrdma_qp_ops.c | 2 ++ 1 file changed, 2 insertions(+)hw/rdma/vmw/pvrdma_qp_ops.c +1
-0@@ -168,6 +168,7 @@ int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle) sgid =rdma_rm_get_gid (&dev->rdma_dev_res, wqe->hdr.wr.ud.av.gid_index);if (!sgid) {pr_dbg ("Fail to get gid for idx %d\n" , wqe->hdr.wr.ud.av.gid_index); +g_free (comp_ctx);return -EIO ; }
Quoted 8 lines
hw/rdma/vmw/pvrdma_qp_ops.c int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle) · line 185
Quoted 8 lines
hw/rdma/vmw/pvrdma_qp_ops.c +1
-0pr_dbg("sgid_id=%d, sgid=0x%llx\n", wqe->hdr.wr.ud.av.gid_index,@@ -179,6 +180,7 @@ int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle)if (sgid_idx <=0 ) {pr_dbg ("Fail to get bk sgid_idx for sgid_idx %d\n" , wqe->hdr.wr.ud.av.gid_index); +g_free (comp_ctx);return -EIO ; }
Since comp_ctx is not used until the two checks are done we just can relocate the allocation & initialization right after the two checks.
Yuval
Quoted 2 lines
Quoted 2 lines
Quoted 29 lines · Yuval Shaia
Quoted 28 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Li Qiang
Spotted by Coverity: CID 1398595
Fixes 2b05705dc8Quoted 1 line
Signed-off-by Li Qiang <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Quoted 18 lines
--- hw/rdma/vmw/pvrdma_qp_ops.c | 2 ++ 1 file changed, 2 insertions(+)hw/rdma/vmw/pvrdma_qp_ops.c +1
-0@@ -168,6 +168,7 @@ int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle) sgid =rdma_rm_get_gid (&dev->rdma_dev_res, wqe->hdr.wr.ud.av.gid_index);if (!sgid) {pr_dbg ("Fail to get gid for idx %d\n" , wqe->hdr.wr.ud.av.gid_index); +g_free (comp_ctx);return -EIO ; } pr_dbg("sgid_id=%d, sgid=0x%llx\n", wqe->hdr.wr.ud.av.gid_index,@@ -179,6 +180,7 @@ int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle)if (sgid_idx <=0 ) {
Quoted 10 lines
Quoted 5 lines
hw/rdma/vmw/pvrdma_qp_ops.c int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle) · line 185
Quoted 5 lines
hw/rdma/vmw/pvrdma_qp_ops.c +1
-0pr_dbg ("Fail to get bk sgid_idx for sgid_idx %d\n" , wqe->hdr.wr.ud.av.gid_index); +g_free (comp_ctx);return -EIO ; }Since
comp_ctxis not used until the two checks are done we just can relocate the allocation & initialization right after the two checks.
OK, will send a revised version later.
Thanks,
Li Qiang
Quoted 4 lines
Yuval
Quoted 2 lines
Quoted 2 lines
Quoted 29 lines · Yuval Shaia
Quoted 28 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Li Qiang
Spotted by Coverity: CID 1398595
Fixes 2b05705dc8Quoted 1 line
Signed-off-by Li Qiang <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Quoted 18 lines
--- hw/rdma/vmw/pvrdma_qp_ops.c | 2 ++ 1 file changed, 2 insertions(+)hw/rdma/vmw/pvrdma_qp_ops.c +1
-0@@ -168,6 +168,7 @@ int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle) sgid =rdma_rm_get_gid (&dev->rdma_dev_res, wqe->hdr.wr.ud.av.gid_index);if (!sgid) {pr_dbg ("Fail to get gid for idx %d\n" , wqe->hdr.wr.ud.av.gid_index); +g_free (comp_ctx);return -EIO ; } pr_dbg("sgid_id=%d, sgid=0x%llx\n", wqe->hdr.wr.ud.av.gid_index,@@ -179,6 +180,7 @@ int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle)if (sgid_idx <=0 ) {
Quoted 8 lines
Quoted 5 lines
hw/rdma/vmw/pvrdma_qp_ops.c int pvrdma_qp_send(PVRDMADev *dev, uint32_t qp_handle) · line 185
Quoted 5 lines
hw/rdma/vmw/pvrdma_qp_ops.c +1
-0pr_dbg ("Fail to get bk sgid_idx for sgid_idx %d\n" , wqe->hdr.wr.ud.av.gid_index); +g_free (comp_ctx);return -EIO ; }Since
comp_ctxis not used until the two checks are done we just can relocate the allocation & initialization right after the two checks.
Oops I missed this, thanks your suggestion is way cleaner!
Phil.