rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] refperf: Set reader_tasks to NULL after kfree()
@ 2025-09-11  3:18 Kaushlendra Kumar
  2025-09-11 19:46 ` Paul E. McKenney
  0 siblings, 1 reply; 2+ messages in thread
From: Kaushlendra Kumar @ 2025-09-11  3:18 UTC (permalink / raw)
  To: dave, paulmck, josh, frederic, neeraj.upadhyay, rostedt
  Cc: linux-kernel, rcu, Kaushlendra Kumar

Set reader_tasks to NULL after kfree() in ref_scale_cleanup() to
improve debugging experience with kernel debugging tools. This
follows the common pattern of NULLing pointers after freeing to
avoid dangling pointer issues during debugging sessions.

Setting pointers to NULL after freeing helps debugging tools like
kdgb,drgn, and other kernel debuggers by providing clear indication
that the memory has been freed and the pointer is no longer valid.

Suggested-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
 kernel/rcu/refscale.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c
index 2bfa987f4ba9..47486dff43ca 100644
--- a/kernel/rcu/refscale.c
+++ b/kernel/rcu/refscale.c
@@ -1048,6 +1048,7 @@ ref_scale_cleanup(void)
 					     reader_tasks[i].task);
 	}
 	kfree(reader_tasks);
+	reader_tasks = NULL;
 
 	torture_stop_kthread("main_task", main_task);
 
-- 
2.34.1


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

end of thread, other threads:[~2025-09-11 19:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-11  3:18 [PATCH] refperf: Set reader_tasks to NULL after kfree() Kaushlendra Kumar
2025-09-11 19:46 ` Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).