Skip to content

Commit 75ce02f

Browse files
wusamuel6rafaeljw
authored andcommitted
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: b4941ad ("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>
1 parent 1081c16 commit 75ce02f

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

drivers/base/power/wakeup.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,7 @@ EXPORT_SYMBOL_GPL(wakeup_sources_read_unlock);
275275
*/
276276
struct wakeup_source *wakeup_sources_walk_start(void)
277277
{
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);
281279
}
282280
EXPORT_SYMBOL_GPL(wakeup_sources_walk_start);
283281

0 commit comments

Comments
 (0)