]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
tools/power x86_energy_perf_policy: Fix potential NULL pointer dereference
authorMalaya Kumar Rout <mrout@redhat.com>
Sat, 22 Nov 2025 15:16:52 +0000 (20:46 +0530)
committerLen Brown <len.brown@intel.com>
Tue, 2 Dec 2025 21:11:09 +0000 (16:11 -0500)
commit51860d6330b6cda355a7e30b3e09e7a22ec4b6ae
tree6af2ee3d76feb9f647d7e822af40af914eede09c
parent7446bd6119fa77f75a41d7870953dbf467ffd40b
tools/power x86_energy_perf_policy: Fix potential NULL pointer dereference

In err_on_hypervisor(), strstr() is called to search for "flags" in the
buffer, but the return value is not checked before being used in pointer
arithmetic (flags - buffer). If strstr() returns NULL because "flags" is
not found in /proc/cpuinfo, this will cause undefined behavior and likely
a crash.

Add a NULL check after the strstr() call and handle the error appropriately
by cleaning up resources and reporting a meaningful error message.

Signed-off-by: Malaya Kumar Rout <mrout@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c