From: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org
Cc: linux-kernel@vger.kernel.org,
Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Subject: [PATCH] sched/deadline: Set cp->elements to NULL after kfree() in cpudl_init()
Date: Fri, 12 Sep 2025 21:43:38 +0530 [thread overview]
Message-ID: <20250912161338.1079085-1-kaushlendra.kumar@intel.com> (raw)
Set cp->elements to NULL after kfree() in the error path of cpudl_init()
to prevent potential use-after-free issues. This ensures that the pointer
is properly invalidated when memory allocation fails for cp->free_cpus,
making the code more robust against accidental access to freed memory.
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.
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
kernel/sched/cpudeadline.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index cdd740b3f774..0f7127b3a05c 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -276,6 +276,7 @@ int cpudl_init(struct cpudl *cp)
if (!zalloc_cpumask_var(&cp->free_cpus, GFP_KERNEL)) {
kfree(cp->elements);
+ cp->elements = NULL;
return -ENOMEM;
}
--
2.34.1
reply other threads:[~2025-09-12 16:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20250912161338.1079085-1-kaushlendra.kumar@intel.com \
--to=kaushlendra.kumar@intel.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
/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
all inboxes | Powered by JetHome®