Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PM: wakeup: Handle empty list in wakeup_sources_walk_start()

In the case of an empty wakeup_sources list, wakeup_sources_walk_start()
will return an invalid but non-NULL address. This also affects wrappers
of the aforementioned function, like for_each_wakeup_source().

Update wakeup_sources_walk_start() to return NULL in case of an empty
list.

Fixes: b4941adb24c0 ("PM: wakeup: Add routine to help fetch wakeup source object.")
Signed-off-by: Samuel Wu <wusamuel@google.com>
[ rjw: Subject and changelog edits ]
Link: https://patch.msgid.link/20260124012133.2451708-2-wusamuel@google.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Samuel Wu and committed by
Rafael J. Wysocki
75ce02f4 1081c164

+1 -3
+1 -3
drivers/base/power/wakeup.c
··· 275 275 */ 276 276 struct wakeup_source *wakeup_sources_walk_start(void) 277 277 { 278 - struct list_head *ws_head = &wakeup_sources; 279 - 280 - return list_entry_rcu(ws_head->next, struct wakeup_source, entry); 278 + return list_first_or_null_rcu(&wakeup_sources, struct wakeup_source, entry); 281 279 } 282 280 EXPORT_SYMBOL_GPL(wakeup_sources_walk_start); 283 281