All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mptcp: pm: Return local variable instead of freed pointer
@ 2025-03-25 16:32 Thorsten Blum
  2025-03-25 18:28 ` Matthieu Baerts
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Thorsten Blum @ 2025-03-25 16:32 UTC (permalink / raw)
  To: Matthieu Baerts, Mat Martineau, Geliang Tang; +Cc: mptcp, Thorsten Blum

Commit e4c28e3d5c090 ("mptcp: pm: move generic PM helpers to pm.c")
removed an unnecessary if-check, which resulted in returning a freed
pointer.

This still works due to the implicit boolean conversion when returning
the freed pointer from mptcp_remove_anno_list_by_saddr(), but it can be
confusing and potentially error-prone. To improve clarity, add a local
variable to explicitly return a boolean value instead. 

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Changes in v2:
- Remove the if-check again as suggested by Matthieu Baerts
- Rephrase the commit message
- Link to v1: https://lore.kernel.org/r/20250325110639.49399-2-thorsten.blum@linux.dev/
---
 net/mptcp/pm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 18b19dbccbba..f4e32187e2c3 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -151,10 +151,12 @@ bool mptcp_remove_anno_list_by_saddr(struct mptcp_sock *msk,
 				     const struct mptcp_addr_info *addr)
 {
 	struct mptcp_pm_add_entry *entry;
+	bool ret;
 
 	entry = mptcp_pm_del_add_timer(msk, addr, false);
+	ret = entry;
 	kfree(entry);
-	return entry;
+	return ret;
 }
 
 bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk)

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-03-26 10:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-25 16:32 [PATCH v2] mptcp: pm: Return local variable instead of freed pointer Thorsten Blum
2025-03-25 18:28 ` Matthieu Baerts
2025-03-25 18:45   ` Thorsten Blum
2025-03-25 19:12     ` Matthieu Baerts
2025-03-25 19:20 ` MPTCP CI
2025-03-26 10:25 ` Matthieu Baerts

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.