* [PATCH] IB/mlx4: Fix memory leaks
@ 2019-08-18 20:23 Wenwen Wang
2019-08-19 11:56 ` Leon Romanovsky
2019-08-20 17:18 ` Doug Ledford
0 siblings, 2 replies; 3+ messages in thread
From: Wenwen Wang @ 2019-08-18 20:23 UTC (permalink / raw)
To: Wenwen Wang
Cc: Yishai Hadas, Doug Ledford, Jason Gunthorpe,
open list:MELLANOX MLX4 IB driver, open list
In mlx4_ib_alloc_pv_bufs(), 'tun_qp->tx_ring' is allocated through
kcalloc(). However, it is not always deallocated in the following execution
if an error occurs, leading to memory leaks. To fix this issue, free
'tun_qp->tx_ring' whenever an error occurs.
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
drivers/infiniband/hw/mlx4/mad.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 68c9514..5707911 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -1677,8 +1677,6 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
tx_buf_size, DMA_TO_DEVICE);
kfree(tun_qp->tx_ring[i].buf.addr);
}
- kfree(tun_qp->tx_ring);
- tun_qp->tx_ring = NULL;
i = MLX4_NUM_TUNNEL_BUFS;
err:
while (i > 0) {
@@ -1687,6 +1685,8 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
rx_buf_size, DMA_FROM_DEVICE);
kfree(tun_qp->ring[i].addr);
}
+ kfree(tun_qp->tx_ring);
+ tun_qp->tx_ring = NULL;
kfree(tun_qp->ring);
tun_qp->ring = NULL;
return -ENOMEM;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] IB/mlx4: Fix memory leaks
2019-08-18 20:23 [PATCH] IB/mlx4: Fix memory leaks Wenwen Wang
@ 2019-08-19 11:56 ` Leon Romanovsky
2019-08-20 17:18 ` Doug Ledford
1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2019-08-19 11:56 UTC (permalink / raw)
To: Wenwen Wang
Cc: Yishai Hadas, Doug Ledford, Jason Gunthorpe,
open list:MELLANOX MLX4 IB driver, open list
On Sun, Aug 18, 2019 at 03:23:01PM -0500, Wenwen Wang wrote:
> In mlx4_ib_alloc_pv_bufs(), 'tun_qp->tx_ring' is allocated through
> kcalloc(). However, it is not always deallocated in the following execution
> if an error occurs, leading to memory leaks. To fix this issue, free
> 'tun_qp->tx_ring' whenever an error occurs.
>
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
Thanks,
Acked-by: Leon Romanovsky <leonro@mellanox.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] IB/mlx4: Fix memory leaks
2019-08-18 20:23 [PATCH] IB/mlx4: Fix memory leaks Wenwen Wang
2019-08-19 11:56 ` Leon Romanovsky
@ 2019-08-20 17:18 ` Doug Ledford
1 sibling, 0 replies; 3+ messages in thread
From: Doug Ledford @ 2019-08-20 17:18 UTC (permalink / raw)
To: Wenwen Wang
Cc: Yishai Hadas, Jason Gunthorpe, open list:MELLANOX MLX4 IB driver,
open list
[-- Attachment #1: Type: text/plain, Size: 563 bytes --]
On Sun, 2019-08-18 at 15:23 -0500, Wenwen Wang wrote:
> In mlx4_ib_alloc_pv_bufs(), 'tun_qp->tx_ring' is allocated through
> kcalloc(). However, it is not always deallocated in the following
> execution
> if an error occurs, leading to memory leaks. To fix this issue, free
> 'tun_qp->tx_ring' whenever an error occurs.
>
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
> ---
Thanks, applied to for-rc.
--
Doug Ledford <dledford@redhat.com>
GPG KeyID: B826A3330E572FDD
Fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-20 17:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-18 20:23 [PATCH] IB/mlx4: Fix memory leaks Wenwen Wang
2019-08-19 11:56 ` Leon Romanovsky
2019-08-20 17:18 ` Doug Ledford
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).