diff mbox series

[mptcp-net] mptcp: use sock_kfree_s instead of kfree

Message ID 6a3e3dd94642cf24f3d6f97fb869d77d7315d5af.1730360928.git.tanggeliang@kylinos.cn (mailing list archive)
State Accepted, archived
Commit 10225fa09def77ce9f459f365c4bd20efaebc6cf
Delegated to: Matthieu Baerts
Headers show
Series [mptcp-net] mptcp: use sock_kfree_s instead of kfree | expand

Checks

Context Check Description
matttbe/build success Build and static analysis OK
matttbe/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
matttbe/shellcheck success MPTCP selftests files have not been modified
matttbe/KVM_Validation__normal warning Unstable: 1 failed test(s): mptcp_connect_mmap
matttbe/KVM_Validation__debug success Success! ✅
matttbe/KVM_Validation__btf-normal__only_bpftest_all_ success Success! ✅
matttbe/KVM_Validation__btf-debug__only_bpftest_all_ success Success! ✅

Commit Message

Geliang Tang Oct. 31, 2024, 7:49 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

The local address entries on userspace_pm_local_addr_list are allocated
by sock_kmalloc(). It's better to use sock_kfree_s() to free each of them
and adjust the allocated size, instead of using kfree().

Fixes: 24430f8bf516 ("mptcp: add address into userspace pm list")
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 net/mptcp/pm_userspace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

MPTCP CI Oct. 31, 2024, 8:58 a.m. UTC | #1
Hi Geliang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal: Unstable: 1 failed test(s): mptcp_connect_mmap 
Matthieu Baerts (NGI0) Oct. 31, 2024, 4:37 p.m. UTC | #2
Hi Geliang,

On 31/10/2024 08:49, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> The local address entries on userspace_pm_local_addr_list are allocated
> by sock_kmalloc(). It's better to use sock_kfree_s() to free each of them
> and adjust the allocated size, instead of using kfree().

Thank you for the fix!

Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

Now in our tree (I slightly modified the commit message to say it is
"required" to use sock_kfree_s()):

New patches for t/upstream-net and t/upstream:
- 10225fa09def: mptcp: use sock_kfree_s instead of kfree
- Results: d72fc6f97589..b3a5bd8682ef (export-net)
- Results: 2e11fab4d3e0..e696c82b4c5f (export)

Tests are now in progress:

- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/06c3fa1ec4966b86c8be0ced5e3764460451ea2c/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/06709216e8b6bb4c80db23131714e85c8043be18/checks

Cheers,
Matt
diff mbox series

Patch

diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index a3b93fb01dd7..f83eeb04d7c9 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -94,6 +94,7 @@  static int mptcp_userspace_pm_delete_local_addr(struct mptcp_sock *msk,
 						struct mptcp_pm_addr_entry *addr)
 {
 	struct mptcp_pm_addr_entry *entry, *tmp;
+	struct sock *sk = (struct sock *)msk;
 
 	list_for_each_entry_safe(entry, tmp, &msk->pm.userspace_pm_local_addr_list, list) {
 		if (mptcp_addresses_equal(&entry->addr, &addr->addr, false)) {
@@ -101,7 +102,7 @@  static int mptcp_userspace_pm_delete_local_addr(struct mptcp_sock *msk,
 			 * be used multiple times (e.g. fullmesh mode).
 			 */
 			list_del_rcu(&entry->list);
-			kfree(entry);
+			sock_kfree_s(sk, entry, sizeof(*entry));
 			msk->pm.local_addr_used--;
 			return 0;
 		}