* [PATCH] sched/deadline: Add bounds check in cpudl_maximum()
@ 2025-09-13 4:23 Kaushlendra Kumar
0 siblings, 0 replies; only message in thread
From: Kaushlendra Kumar @ 2025-09-13 4:23 UTC (permalink / raw)
To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann, rostedt
Cc: linux-kernel, Kaushlendra Kumar
Add a bounds check to cpudl_maximum() to prevent accessing cp->elements[0]
when the heap is empty. Return -1 when cp->size is 0 to indicate that no
valid CPU is available in the deadline heap.
Without this check, accessing cp->elements[0] when the heap is empty could
lead to undefined behavior.
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
kernel/sched/cpudeadline.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index 0f7127b3a05c..dd736e3879c8 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -103,6 +103,8 @@ static void cpudl_heapify(struct cpudl *cp, int idx)
static inline int cpudl_maximum(struct cpudl *cp)
{
+ if (cp->size == 0)
+ return -1;
return cp->elements[0].cpu;
}
--
2.34.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-09-13 4:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-13 4:23 [PATCH] sched/deadline: Add bounds check in cpudl_maximum() Kaushlendra Kumar
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®