From: Mahanta Jambigi <mjambigi@linux.ibm.com>
To: Yifei Gao <gyf161023@gmail.com>,
"D . Wythe" <alibuda@linux.alibaba.com>,
Dust Li <dust.li@linux.alibaba.com>,
Sidraya Jayagond <sidraya@linux.ibm.com>,
linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
netdev@vger.kernel.org, Hidayath Khan <hidayath@linux.ibm.com>
Cc: Tony Lu <tonylu@linux.alibaba.com>,
Wen Gu <guwen@linux.alibaba.com>,
Karsten Graul <kgraul@linux.ibm.com>,
Ursula Braun <ubraun@linux.ibm.com>,
Wenjia Zhang <wenjia@linux.ibm.com>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] net/smc: fix sock refcount leak in smc_switch_conns() error path
Date: Wed, 5 Aug 2026 10:10:17 +0530 [thread overview]
Message-ID: <66d3bcd7-1c2e-4bc9-b7af-4ecfd85ae6cb@linux.ibm.com> (raw)
In-Reply-To: <20260804213917.3413525-1-gyf161023@gmail.com>
On 05/08/26 3:09 am, Yifei Gao wrote:
> smc_switch_conns() takes a reference on the socket with sock_hold() before
> dropping conns_lock to prefetch a tx slot. On success the reference is
> released by the sock_put() after smc_switch_cursor(). When
> smc_cdc_get_free_slot() fails, however, the function jumps straight to
> err_out without a sock_put(), leaking the reference and leaving the socket
> unreclaimable. During SMC-R link failover with an exhausted backup link
> this leaks one reference per failing connection switch.
>
> Release the reference before jumping to err_out. The err_out label is also
> reached from the smc_switch_cursor() failure path, which has already done
> its own sock_put(), so the put must stay at the get_free_slot failure site
> rather than at the label.
>
> Fixes: c6f02ebeea3a ("net/smc: switch connections to alternate link")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Yifei Gao <gyf161023@gmail.com>
> ---
> net/smc/smc_core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
> index cf6b620fef05..04c6ce608ec7 100644
> --- a/net/smc/smc_core.c
> +++ b/net/smc/smc_core.c
> @@ -1148,8 +1148,10 @@ struct smc_link *smc_switch_conns(struct smc_link_group *lgr,
> read_unlock_bh(&lgr->conns_lock);
> /* pre-fetch buffer outside of send_lock, might sleep */
> rc = smc_cdc_get_free_slot(conn, to_lnk, &wr_buf, NULL, &pend);
> - if (rc)
> + if (rc) {
> + sock_put(&smc->sk);
> goto err_out;
> + }
This patch has already been posted by Hidayath:
https://lore.kernel.org/netdev/20260804082800.498672-1-hidayath@linux.ibm.com/
Adding Hidayath to confirm, but this appears to be a duplicate submission.
next prev parent reply other threads:[~2026-08-05 4:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 21:39 [PATCH] net/smc: fix sock refcount leak in smc_switch_conns() error path Yifei Gao
2026-08-05 3:18 ` Tony Lu
2026-08-05 4:40 ` Mahanta Jambigi [this message]
2026-08-05 6:26 ` Hidayathulla Khan I
2026-08-06 15:00 ` 高逸飞
2026-08-05 21:39 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=66d3bcd7-1c2e-4bc9-b7af-4ecfd85ae6cb@linux.ibm.com \
--to=mjambigi@linux.ibm.com \
--cc=alibuda@linux.alibaba.com \
--cc=dust.li@linux.alibaba.com \
--cc=guwen@linux.alibaba.com \
--cc=gyf161023@gmail.com \
--cc=hidayath@linux.ibm.com \
--cc=kgraul@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sidraya@linux.ibm.com \
--cc=stable@vger.kernel.org \
--cc=tonylu@linux.alibaba.com \
--cc=ubraun@linux.ibm.com \
--cc=wenjia@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.