mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-06 17:35:20 +02:00
net/smc: Fix memory leak when using percpu refs
[ Upstream commit25c12b459d
] This patch adds missing percpu_ref_exit when releasing percpu refs. When releasing percpu refs, percpu_ref_exit should be called. Otherwise, memory leak happens. Fixes:79a22238b4
("net/smc: Use percpu ref for wr tx reference") Signed-off-by: Kai Shen <KaiShen@linux.alibaba.com> Reviewed-by: Dust Li <dust.li@linux.alibaba.com> Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com> Link: https://patch.msgid.link/20241010115624.7769-1-KaiShen@linux.alibaba.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
95e3da2681
commit
a17874a3a5
|
@ -648,8 +648,10 @@ void smc_wr_free_link(struct smc_link *lnk)
|
|||
smc_wr_tx_wait_no_pending_sends(lnk);
|
||||
percpu_ref_kill(&lnk->wr_reg_refs);
|
||||
wait_for_completion(&lnk->reg_ref_comp);
|
||||
percpu_ref_exit(&lnk->wr_reg_refs);
|
||||
percpu_ref_kill(&lnk->wr_tx_refs);
|
||||
wait_for_completion(&lnk->tx_ref_comp);
|
||||
percpu_ref_exit(&lnk->wr_tx_refs);
|
||||
|
||||
if (lnk->wr_rx_dma_addr) {
|
||||
ib_dma_unmap_single(ibdev, lnk->wr_rx_dma_addr,
|
||||
|
@ -912,11 +914,13 @@ int smc_wr_create_link(struct smc_link *lnk)
|
|||
init_waitqueue_head(&lnk->wr_reg_wait);
|
||||
rc = percpu_ref_init(&lnk->wr_reg_refs, smcr_wr_reg_refs_free, 0, GFP_KERNEL);
|
||||
if (rc)
|
||||
goto dma_unmap;
|
||||
goto cancel_ref;
|
||||
init_completion(&lnk->reg_ref_comp);
|
||||
init_waitqueue_head(&lnk->wr_rx_empty_wait);
|
||||
return rc;
|
||||
|
||||
cancel_ref:
|
||||
percpu_ref_exit(&lnk->wr_tx_refs);
|
||||
dma_unmap:
|
||||
if (lnk->wr_rx_v2_dma_addr) {
|
||||
ib_dma_unmap_single(ibdev, lnk->wr_rx_v2_dma_addr,
|
||||
|
|
Loading…
Reference in New Issue
Block a user