Re: [PATCH] PM: wakelocks: Fix off-by-one in wakeup source limit
From: Rafael J. Wysocki (Intel)
Date: Mon Jul 06 2026 - 15:01:06 EST
On Wed, Jun 24, 2026 at 7:39 AM Haowen Tu <tuhaowen@xxxxxxxxxxxxx> wrote:
>
> CONFIG_PM_WAKELOCKS_LIMIT is documented as the maximum number of
> user-space wakeup sources. However, the limit check is performed before
> the counter is incremented and only rejects new wakeup sources when the
> current number is greater than the limit. This allows one extra wakeup
> source to be created.
>
> Reject new wakeup sources once the counter has reached the limit.
>
> Fixes: b86ff9820fd5 ("PM / Sleep: Add user space interface for manipulating wakeup sources, v3")
> Signed-off-by: Haowen Tu <tuhaowen@xxxxxxxxxxxxx>
> ---
> kernel/power/wakelock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/power/wakelock.c b/kernel/power/wakelock.c
> index fd763da06a87..a8b6bd5ec46b 100644
> --- a/kernel/power/wakelock.c
> +++ b/kernel/power/wakelock.c
> @@ -63,7 +63,7 @@ static unsigned int number_of_wakelocks;
>
> static inline bool wakelocks_limit_exceeded(void)
> {
> - return number_of_wakelocks > CONFIG_PM_WAKELOCKS_LIMIT;
> + return number_of_wakelocks >= CONFIG_PM_WAKELOCKS_LIMIT;
> }
>
> static inline void increment_wakelocks_number(void)
> --
Applied as 7.3 material, thanks!