* [PATCH] IB/mad: fix possible memory leak in ib_mad_post_receive_mads()
@ 2020-06-12 6:38 Guo Fan
2020-06-19 12:24 ` Jason Gunthorpe
0 siblings, 1 reply; 2+ messages in thread
From: Guo Fan @ 2020-06-12 6:38 UTC (permalink / raw)
To: jgg, leon; +Cc: linux-kernel, linux-rdma
From: Fan Guo <guofan5@huawei.com>
If ib_dma_mapping_error() returns non-zero value, ib_mad_post_receive_mads
will jump out of loops and return -ENOMEM without freeing mad_priv. We fix
this memory-leak problem by freeing mad_priv in this case.
Fixes: 2c34e68f4261 ("IB/mad: Check and handle potential DMA mapping errors")
Signed-off-by: Fan Guo <guofan5@huawei.com>
---
drivers/infiniband/core/mad.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 186e0d652e8b..5e080191a725 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -2718,6 +2718,7 @@ static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
DMA_FROM_DEVICE);
if (unlikely(ib_dma_mapping_error(qp_info->port_priv->device,
sg_list.addr))) {
+ kfree(mad_priv);
ret = -ENOMEM;
break;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] IB/mad: fix possible memory leak in ib_mad_post_receive_mads()
2020-06-12 6:38 [PATCH] IB/mad: fix possible memory leak in ib_mad_post_receive_mads() Guo Fan
@ 2020-06-19 12:24 ` Jason Gunthorpe
0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2020-06-19 12:24 UTC (permalink / raw)
To: Guo Fan; +Cc: leon, linux-kernel, linux-rdma
On Fri, Jun 12, 2020 at 02:38:24PM +0800, Guo Fan wrote:
> From: Fan Guo <guofan5@huawei.com>
>
> If ib_dma_mapping_error() returns non-zero value, ib_mad_post_receive_mads
> will jump out of loops and return -ENOMEM without freeing mad_priv. We fix
> this memory-leak problem by freeing mad_priv in this case.
>
> Fixes: 2c34e68f4261 ("IB/mad: Check and handle potential DMA mapping errors")
> Signed-off-by: Fan Guo <guofan5@huawei.com>
> ---
> drivers/infiniband/core/mad.c | 1 +
> 1 file changed, 1 insertion(+)
Applied to for-rc, thanks
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-19 12:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-12 6:38 [PATCH] IB/mad: fix possible memory leak in ib_mad_post_receive_mads() Guo Fan
2020-06-19 12:24 ` Jason Gunthorpe
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).