Skip to content

Commit 27ae58a

Browse files
Fan GuoSasha Levin
authored andcommitted
RDMA/mad: Fix possible memory leak in ib_mad_post_receive_mads()
[ Upstream commit a17f4be ] 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. Fix this memory-leak problem by freeing mad_priv in this case. Fixes: 2c34e68 ("IB/mad: Check and handle potential DMA mapping errors") Link: https://lore.kernel.org/r/20200612063824.180611-1-guofan5@huawei.com Signed-off-by: Fan Guo <guofan5@huawei.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 773cc91 commit 27ae58a

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

  • drivers/infiniband/core

‎drivers/infiniband/core/mad.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2941,6 +2941,7 @@ static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
29412941
DMA_FROM_DEVICE);
29422942
if (unlikely(ib_dma_mapping_error(qp_info->port_priv->device,
29432943
sg_list.addr))) {
2944+
kfree(mad_priv);
29442945
ret = -ENOMEM;
29452946
break;
29462947
}

0 commit comments

Comments
 (0)