Commit 75ce02f4 authored by Samuel Wu's avatar Samuel Wu Committed by Rafael J. Wysocki
Browse files

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: b4941adb ("PM: wakeup: Add routine to help fetch wakeup source object.")
Signed-off-by: default avatarSamuel Wu <wusamuel@google.com>
[ rjw: Subject and changelog edits ]
Link: https://patch.msgid.link/20260124012133.2451708-2-wusamuel@google.com


Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 1081c164
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -275,9 +275,7 @@ EXPORT_SYMBOL_GPL(wakeup_sources_read_unlock);
 */
struct wakeup_source *wakeup_sources_walk_start(void)
{
	struct list_head *ws_head = &wakeup_sources;

	return list_entry_rcu(ws_head->next, struct wakeup_source, entry);
	return list_first_or_null_rcu(&wakeup_sources, struct wakeup_source, entry);
}
EXPORT_SYMBOL_GPL(wakeup_sources_walk_start);