Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/smc: put sk reference if close work was canceled

Note that we always hold a reference to sock when attempting
to submit close_work. Therefore, if we have successfully
canceled close_work from pending, we MUST release that reference
to avoid potential leaks.

Fixes: 42bfba9eaa33 ("net/smc: immediate termination for SMCD link groups")
Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
Reviewed-by: Dust Li <dust.li@linux.alibaba.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

D. Wythe and committed by
David S. Miller
aa96fbd6 c5bf605b

+2 -1
+2 -1
net/smc/smc_close.c
··· 116 116 struct sock *sk = &smc->sk; 117 117 118 118 release_sock(sk); 119 - cancel_work_sync(&smc->conn.close_work); 119 + if (cancel_work_sync(&smc->conn.close_work)) 120 + sock_put(sk); 120 121 cancel_delayed_work_sync(&smc->conn.tx_work); 121 122 lock_sock(sk); 122 123 }