* [Qemu-devel] [PATCH] hw: pvrdma: fix memory leak in error path
@ 2019-01-03 13:03 Li Qiang
2019-01-03 13:47 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 5+ messages in thread
From: Li Qiang @ 2019-01-03 13:03 UTC (permalink / raw)
To: yuval.shaia, marcel.apfelbaum; +Cc: qemu-devel, peter.maydell, Li Qiang
Spotted by Coverity: CID 1398595
Signed-off-by: Li Qiang <liq3ea@163.com>
---
hw/rdma/vmw/pvrdma_qp_ops.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/rdma/vmw/pvrdma_qp_ops.c b/hw/rdma/vmw/pvrdma_qp_ops.c
index 300471a4c9..584be2043e 100644
--- a/hw/rdma/vmw/pvrdma_qp_ops.c
+++ b/hw/rdma/vmw/pvrdma_qp_ops.c
@@ -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;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] hw: pvrdma: fix memory leak in error path
2019-01-03 13:03 [Qemu-devel] [PATCH] hw: pvrdma: fix memory leak in error path Li Qiang
@ 2019-01-03 13:47 ` Philippe Mathieu-Daudé
2019-01-07 16:26 ` Yuval Shaia
0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-01-03 13:47 UTC (permalink / raw)
To: Li Qiang, yuval.shaia, marcel.apfelbaum; +Cc: peter.maydell, qemu-devel
On 1/3/19 2:03 PM, Li Qiang wrote:
> Spotted by Coverity: CID 1398595
>
Fixes: 2b05705dc8
> Signed-off-by: Li Qiang <liq3ea@163.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/rdma/vmw/pvrdma_qp_ops.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/hw/rdma/vmw/pvrdma_qp_ops.c b/hw/rdma/vmw/pvrdma_qp_ops.c
> index 300471a4c9..584be2043e 100644
> --- a/hw/rdma/vmw/pvrdma_qp_ops.c
> +++ b/hw/rdma/vmw/pvrdma_qp_ops.c
> @@ -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;
> }
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] hw: pvrdma: fix memory leak in error path
2019-01-03 13:47 ` Philippe Mathieu-Daudé
@ 2019-01-07 16:26 ` Yuval Shaia
2019-01-08 6:40 ` 李强
2019-01-08 17:47 ` Philippe Mathieu-Daudé
0 siblings, 2 replies; 5+ messages in thread
From: Yuval Shaia @ 2019-01-07 16:26 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, liq3ea
Cc: marcel.apfelbaum, peter.maydell, qemu-devel, yuval.shaia
On Thu, Jan 03, 2019 at 02:47:37PM +0100, Philippe Mathieu-Daudé wrote:
> On 1/3/19 2:03 PM, Li Qiang wrote:
> > Spotted by Coverity: CID 1398595
> >
>
> Fixes: 2b05705dc8
>
> > Signed-off-by: Li Qiang <liq3ea@163.com>
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>
> > ---
> > hw/rdma/vmw/pvrdma_qp_ops.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/hw/rdma/vmw/pvrdma_qp_ops.c b/hw/rdma/vmw/pvrdma_qp_ops.c
> > index 300471a4c9..584be2043e 100644
> > --- a/hw/rdma/vmw/pvrdma_qp_ops.c
> > +++ b/hw/rdma/vmw/pvrdma_qp_ops.c
> > @@ -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;
> > }
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
> >
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] hw: pvrdma: fix memory leak in error path
2019-01-07 16:26 ` Yuval Shaia
@ 2019-01-08 6:40 ` 李强
2019-01-08 17:47 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 5+ messages in thread
From: 李强 @ 2019-01-08 6:40 UTC (permalink / raw)
To: Yuval Shaia
Cc: Philippe Mathieu-Daudé, marcel.apfelbaum, peter.maydell,
qemu-devel
At 2019-01-08 00:26:58, "Yuval Shaia" <yuval.shaia@oracle.com> wrote:
>On Thu, Jan 03, 2019 at 02:47:37PM +0100, Philippe Mathieu-Daudé wrote:
>> On 1/3/19 2:03 PM, Li Qiang wrote:
>> > Spotted by Coverity: CID 1398595
>> >
>>
>> Fixes: 2b05705dc8
>>
>> > Signed-off-by: Li Qiang <liq3ea@163.com>
>>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>
>> > ---
>> > hw/rdma/vmw/pvrdma_qp_ops.c | 2 ++
>> > 1 file changed, 2 insertions(+)
>> >
>> > diff --git a/hw/rdma/vmw/pvrdma_qp_ops.c b/hw/rdma/vmw/pvrdma_qp_ops.c
>> > index 300471a4c9..584be2043e 100644
>> > --- a/hw/rdma/vmw/pvrdma_qp_ops.c
>> > +++ b/hw/rdma/vmw/pvrdma_qp_ops.c
>> > @@ -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;
>> > }
>
>Since comp_ctx is 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
>Yuval
>
>> >
>> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] hw: pvrdma: fix memory leak in error path
2019-01-07 16:26 ` Yuval Shaia
2019-01-08 6:40 ` 李强
@ 2019-01-08 17:47 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-01-08 17:47 UTC (permalink / raw)
To: Yuval Shaia, liq3ea; +Cc: marcel.apfelbaum, peter.maydell, qemu-devel
On 1/7/19 5:26 PM, Yuval Shaia wrote:
> On Thu, Jan 03, 2019 at 02:47:37PM +0100, Philippe Mathieu-Daudé wrote:
>> On 1/3/19 2:03 PM, Li Qiang wrote:
>>> Spotted by Coverity: CID 1398595
>>>
>>
>> Fixes: 2b05705dc8
>>
>>> Signed-off-by: Li Qiang <liq3ea@163.com>
>>
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>
>>> ---
>>> hw/rdma/vmw/pvrdma_qp_ops.c | 2 ++
>>> 1 file changed, 2 insertions(+)
>>>
>>> diff --git a/hw/rdma/vmw/pvrdma_qp_ops.c b/hw/rdma/vmw/pvrdma_qp_ops.c
>>> index 300471a4c9..584be2043e 100644
>>> --- a/hw/rdma/vmw/pvrdma_qp_ops.c
>>> +++ b/hw/rdma/vmw/pvrdma_qp_ops.c
>>> @@ -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;
>>> }
>
> Since comp_ctx is 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-08 17:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-03 13:03 [Qemu-devel] [PATCH] hw: pvrdma: fix memory leak in error path Li Qiang
2019-01-03 13:47 ` Philippe Mathieu-Daudé
2019-01-07 16:26 ` Yuval Shaia
2019-01-08 6:40 ` 李强
2019-01-08 17:47 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).