From nobody Thu Apr 9 14:09:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BA85846A for ; Sun, 8 Mar 2026 02:31:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772937077; cv=none; b=CMLzT0G3K8iD1OuEOnAV7Lbqz/hoZbXoivqrXJlh10gVlQ+TOBYpA/FgGQq5XEvL8m18DCRc5ZevR8vUsAYcGDZ+0m+1xeD3GjjV518BQ/d2FS7VaMf/5LSd3yyr+cv/CraHLvSBQfpm4ox3sqnCEHSWfkeNraJ8Cysug0odt9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772937077; c=relaxed/simple; bh=iW36BjnpqoJUoYf70qDIygbQwfj2KLQZ/F3JePjcSSg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=G3ZbQe7Cx39SPY8uuEvxkGpywxCMRvwJ8j0qvuJqHANtkBHLmjzCLtpX++oZIcHYLwMlKvZe1VrLAwm3pAzhVkQN2YHaUYSY24rFwTe7CR2qUnCIM1UCuT56QQpDxj9XZyRhNIDADRHMka72DSjGjZKxN7a5qqEAKaKKWaLF5mQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EDA7C19422; Sun, 8 Mar 2026 02:31:16 +0000 (UTC) From: Joseph Salisbury To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot Cc: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , linux-kernel@vger.kernel.org Subject: [PATCH] sched/cpupri: handle out-of-range prio in convert_prio Date: Sat, 7 Mar 2026 21:31:15 -0500 Message-ID: <20260308023115.72134-1-joseph.salisbury@oracle.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" convert_prio() can return an undefined value when called with an out-of-range priority because 'cpupri' is not initialized on the default path. Initialize 'cpupri' to 'CPUPRI_INVALID' and warn once on invalid input, keeping behavior deterministic for unexpected priorities. Fixes: 6e0534f27819 ("sched: use a 2-d bitmap for searching lowest-pri CPU") Cc: stable@vger.kernel.org Assisted-by: Codex:GPT-5 Signed-off-by: Joseph Salisbury --- kernel/sched/cpupri.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c index 8f2237e8b484..b905a6bfac0c 100644 --- a/kernel/sched/cpupri.c +++ b/kernel/sched/cpupri.c @@ -42,7 +42,7 @@ */ static int convert_prio(int prio) { - int cpupri; + int cpupri =3D CPUPRI_INVALID; =20 switch (prio) { case CPUPRI_INVALID: @@ -60,6 +60,10 @@ static int convert_prio(int prio) case MAX_RT_PRIO: cpupri =3D CPUPRI_HIGHER; /* 100 */ break; + + default: + WARN_ON_ONCE(prio < 0 || prio > MAX_RT_PRIO); + break; } =20 return cpupri; --=20 2.47.3