RDMA/mad: Fix possible memory leak in ib_mad_post_receive_mads()
authorFan Guo <guofan5@huawei.com>
Fri, 12 Jun 2020 06:38:24 +0000 (14:38 +0800)
committerSasha Levin <sashal@kernel.org>
Wed, 1 Jul 2020 03:17:11 +0000 (23:17 -0400)
commitd6d76e02802865ac710145f7b9f2ae6c0aa0415c
treefa576749b965e9a2eaa6ff15bf11999d42b03767
parentdf5888912859c26b9d7cb825eb26920f5e0f9c67
RDMA/mad: Fix possible memory leak in ib_mad_post_receive_mads()

[ Upstream commit a17f4bed811c60712d8131883cdba11a105d0161 ]

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: 2c34e68f4261 ("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>
drivers/infiniband/core/mad.c