From: Wen Gu <guwen@linux.alibaba.com>
To: wenjia@linux.ibm.com, jaka@linux.ibm.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com
Cc: alibuda@linux.alibaba.com, tonylu@linux.alibaba.com,
guwen@linux.alibaba.com, linux-s390@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net] net/smc: delete buf_desc from buffer list under lock protection
Date: Wed, 31 Jul 2024 17:31:02 +0800 [thread overview]
Message-ID: <20240731093102.130154-1-guwen@linux.alibaba.com> (raw)
The operations to link group buffer list should be protected by
sndbufs_lock or rmbs_lock. So fix it.
Fixes: 3e034725c0d8 ("net/smc: common functions for RMBs and send buffers")
Signed-off-by: Wen Gu <guwen@linux.alibaba.com>
---
net/smc/smc_core.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index 3b95828d9976..ecfea8c38da9 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -1368,18 +1368,24 @@ static void __smc_lgr_free_bufs(struct smc_link_group *lgr, bool is_rmb)
{
struct smc_buf_desc *buf_desc, *bf_desc;
struct list_head *buf_list;
+ struct rw_semaphore *lock;
int i;
for (i = 0; i < SMC_RMBE_SIZES; i++) {
- if (is_rmb)
+ if (is_rmb) {
buf_list = &lgr->rmbs[i];
- else
+ lock = &lgr->rmbs_lock;
+ } else {
buf_list = &lgr->sndbufs[i];
+ lock = &lgr->sndbufs_lock;
+ }
+ down_write(lock);
list_for_each_entry_safe(buf_desc, bf_desc, buf_list,
list) {
list_del(&buf_desc->list);
smc_buf_free(lgr, is_rmb, buf_desc);
}
+ up_write(lock);
}
}
--
2.32.0.3.g01195cf9f
next reply other threads:[~2024-07-31 9:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-31 9:31 Wen Gu [this message]
2024-07-31 10:32 ` [PATCH net] net/smc: delete buf_desc from buffer list under lock protection shaozhengchao
2024-08-02 1:55 ` Wen Gu
2024-08-05 8:23 ` Wenjia Zhang
2024-08-05 9:31 ` Wen Gu
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=20240731093102.130154-1-guwen@linux.alibaba.com \
--to=guwen@linux.alibaba.com \
--cc=alibuda@linux.alibaba.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jaka@linux.ibm.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tonylu@linux.alibaba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox