]> git.baikalelectronics.ru Git - kernel.git/commit
RDMA/siw: Fix potential siw_mem refcnt leak in siw_fastreg_mr()
authorJason Gunthorpe <jgg@mellanox.com>
Wed, 15 Apr 2020 14:09:22 +0000 (11:09 -0300)
committerJason Gunthorpe <jgg@mellanox.com>
Wed, 15 Apr 2020 14:26:51 +0000 (11:26 -0300)
commitecd7ef9619193665a89ba81523ca26ebcfcd39a5
tree5635c7d9dd6cf171723e8f9c8fc8f201d5eb3c4b
parent72d10773a28c701937c29f6702b0dfda9c047031
RDMA/siw: Fix potential siw_mem refcnt leak in siw_fastreg_mr()

siw_fastreg_mr() invokes siw_mem_id2obj(), which returns a local reference
of the siw_mem object to "mem" with increased refcnt.  When
siw_fastreg_mr() returns, "mem" becomes invalid, so the refcount should be
decreased to keep refcount balanced.

The issue happens in one error path of siw_fastreg_mr(). When "base_mr"
equals to NULL but "mem" is not NULL, the function forgets to decrease the
refcnt increased by siw_mem_id2obj() and causes a refcnt leak.

Reorganize the flow so that the goto unwind can be used as expected.

Fixes: fac165e35a96 ("rdma/siw: transmit path")
Link: https://lore.kernel.org/r/1586939949-69856-1-git-send-email-xiyuyang19@fudan.edu.cn
Reported-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/sw/siw/siw_qp_tx.c