git: 25d0c5d4456f - stable/15 - cpufreq(4): cpufreq_levels_sysctl(): Remove always false NULL test

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Mon, 30 Mar 2026 09:36:32 UTC
The branch stable/15 has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=25d0c5d4456f2c9b01d43bd3717d2bc2d8a3b83d

commit 25d0c5d4456f2c9b01d43bd3717d2bc2d8a3b83d
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2026-02-12 12:33:46 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-03-30 09:36:02 +0000

    cpufreq(4): cpufreq_levels_sysctl(): Remove always false NULL test
    
    'sc->levels_buf' is initialized with malloc(M_WAITOK), so can never be
    NULL.  Another sysctl handler function (cpufreq_curr_sysctl()) already
    relies on that.
    
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 953b9164c3d93e820a53b4fdebbde7fabb7b7644)
---
 sys/kern/kern_cpu.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/sys/kern/kern_cpu.c b/sys/kern/kern_cpu.c
index 1fb3d8002c7f..03d2d38e1749 100644
--- a/sys/kern/kern_cpu.c
+++ b/sys/kern/kern_cpu.c
@@ -1002,16 +1002,12 @@ cpufreq_levels_sysctl(SYSCTL_HANDLER_ARGS)
 	struct sbuf sb;
 	int count, error, i;
 
-	sc = oidp->oid_arg1;
 	sbuf_new(&sb, NULL, 128, SBUF_AUTOEXTEND);
 
 	/* Get settings from the device and generate the output string. */
-	count = CF_MAX_LEVELS;
+	sc = oidp->oid_arg1;
 	levels = sc->levels_buf;
-	if (levels == NULL) {
-		sbuf_delete(&sb);
-		return (ENOMEM);
-	}
+	count = CF_MAX_LEVELS;
 	error = CPUFREQ_LEVELS(sc->dev, levels, &count);
 	if (error) {
 		if (error == E2BIG)