Bug 217386

Summary: intel_powerclamp null pointer dereference in Linux 6.3.x
Product: Power Management Reporter: Risto A. Paju (teknohog)
Component: OtherAssignee: Rafael J. Wysocki (rjw)
Status: NEW ---    
Severity: normal CC: srinivas.pandruvada
Priority: P3    
Hardware: All   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:
Attachments: dmesg-6.3.1
dmesg-6.3.1 on an i5-7300HQ
Patch to fix

Description Risto A. Paju 2023-05-01 09:49:03 UTC
Created attachment 304199 [details]
dmesg-6.3.1

I use intel_powerclamp on a Thinkpad X220i via a custom script for thermal management, and it triggers a kernel bug in Linux 6.3.0 and 6.3.1. The script has a part

awk something > /sys/class/thermal/cooling_device4/cur_state

and the awk process hangs, with the null pointer bug reported in dmesg.

The script has worked fine for years, and for now I've switched back to the 6.2 series for this laptop.
Comment 1 Risto A. Paju 2023-05-01 12:23:15 UTC
The affected CPU is an i3-2310M. I tested the same on a newer Intel laptop with an i5-7300HQ, and there's no sign of the bug there.
Comment 2 Risto A. Paju 2023-05-02 16:45:32 UTC
Created attachment 304202 [details]
dmesg-6.3.1 on an i5-7300HQ

Well, I managed to trigger the bug on an i5-7300HQ too.
Comment 3 Srinivas Pandruvada 2023-05-03 20:57:23 UTC
Created attachment 304209 [details]
Patch to fix

Thanks for reporting. Please try the attached.
I  can reproduce and this patch fixed. Please try.
Comment 4 Risto A. Paju 2023-05-03 22:35:53 UTC
(In reply to Srinivas Pandruvada from comment #3)
> Created attachment 304209 [details]
> Patch to fix
> 
> Thanks for reporting. Please try the attached.
> I  can reproduce and this patch fixed. Please try.

Tested on both machines, the patch fixes it in both cases. Thank you!
Comment 5 Srinivas Pandruvada 2023-05-03 23:40:53 UTC
Thanks. Submitted patch with Tested by tag.