Re: [PATCH RESEND 0/4] Fix some errors in the devfreq core layer when governor is NULL

From: Yaxiong Tian

Date: Thu Mar 26 2026 - 21:55:47 EST



在 2026/3/25 18:06, Jie Zhan 写道:

On 3/19/2026 5:14 PM, Yaxiong Tian wrote:
While doing some development work with devfreq_add_governor()/
devfreq_remove_governor(), I discovered several bugs caused when
devfreq->governor is NULL. Specifically:

1) A possible null pointer issue in devfreq_add_governor(), caused
by devfreq_remove_governor() setting devfreq->governor to NULL in
certain situations, while devfreq_add_governor() lacks corresponding
checks for devfreq->governor.

2) When operating on governor and available_governors under /sys,
there are also some unexpected errors.

See the following patches for details.
Hi Yaxiong,

Sorry for catching this late.

I happen to be working on the same issues recently on a local tree, though
delayed for quite a while due to other business.

It would be a totally different approach by reworking the locking logic,
which, I supposed, can make the devfreq framework cleaner to maintain.

I'll send it out shortly. Hopefully it can be a reference for us to
discuss with.

Thanks!
Jie

Hi Jie
Thank you for your reply. I saw your PATCH in the public linked list, and I think your optimization work, such as the lock mechanism improvements, should be placed after my FIX. This will make it easier to backport the patches and fix lower-version kernels.
I see the patch is already in the devfreq-testing branch. I hope this work can be pushed forward as soon as possible to resolve the null pointer and other bugs.
Finally, if you have any further optimizations, remember to CC me on the patches. :)

Yaxiong Tian (4):
PM / devfreq: Fix possible null pointer issue in
devfreq_add_governor()
PM / devfreq: Fix available_governors_show() when no governor is set
PM / devfreq: Fix governor_store() failing when device has no current
governor
PM / devfreq: Optimize error return value of governor_show()

drivers/devfreq/devfreq.c | 46 +++++++++++++++++++++------------------
1 file changed, 25 insertions(+), 21 deletions(-)