mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 21:38:32 +08:00
IB/mlx4: Fix memory leaks
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> Acked-by: Leon Romanovsky <leonro@mellanox.com> Link: https://lore.kernel.org/r/1566159781-4642-1-git-send-email-wenwen@cs.uga.edu Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
a7bfb93f02
commit
5c1baaa82c
@ -1677,8 +1677,6 @@ tx_err:
|
||||
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 @@ err:
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user