From 8808bc83d4e1ad55b62165d233e6797eac2ade36 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Fri, 17 Nov 2023 16:56:17 +0800 Subject: [PATCH] mptcp: dup an entry when removing it In some cases, the address entry doesn't need to be freed. This patch dups an entry into the free_list to separate removing an address from freeing an entry, so that the refcount of address entry can be added later. Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index af9bd7950fa9b3..8879792ffa7ab4 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -311,10 +311,18 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) goto out; } - list_move(&match->list, &free_list); + entry = kmemdup(match, sizeof(*match), GFP_ATOMIC); + if (!entry) { + err = -ENOMEM; + goto out; + } + list_add(&entry->list, &free_list); mptcp_pm_remove_addrs(msk, &free_list); + list_del_rcu(&match->list); + kfree(match); + release_sock(sk); list_for_each_entry_safe(match, entry, &free_list, list) {