From nobody Mon Feb 9 02:27:06 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BA6C1DE4DC for ; Sat, 24 Jan 2026 01:22:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769217723; cv=none; b=dlqFUDtQld+CB+UBx6xgFgzRI/dwuDyfttxrNvQDXfZivChVdMl/S9HigCgoo+jEyzByTKhP2F88/FtmIK1FhDe3slLHhahtmZud2NWS96b79g3LvyL2h3EqpVTp/LBvjd/WO9d03n+uFLE/BcXUWJIyHJfk3llrYUtfazODNZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769217723; c=relaxed/simple; bh=wvQSevTks610RBfJ7oBqtsKqCB/HWm0eJW4rW75kywU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=CtjnFHkfX0ykzMuQOAaYsdaCO3Ze7vpvmsFvVb51G5EdcIPJw4f3fxOQ+HmmnlBjCDxvt/evqedT438VO06FbF393Wab00FjmhMopdFDjKtYIBb+fiZN9T3Gd1oMlUYvgvClvOP0JKRRV1XkK0lp4fwpO6TDsWwhJezkBBmQlD4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--wusamuel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=YLYZQwrZ; arc=none smtp.client-ip=74.125.82.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--wusamuel.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YLYZQwrZ" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-12338749ea9so3711966c88.0 for ; Fri, 23 Jan 2026 17:22:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769217720; x=1769822520; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=a577FNgbL0JbRd6IsOu504RokGc/26jdmHoERsXu7xE=; b=YLYZQwrZQdClNm0+ozko3XXQMt5QHTLB7dWO7oLhxt0v1xuuJ3CcXIKg54k0W/Qomp 1IMBOsUl6CvRmULjpxw6yiTLZW0Zn9lGrvDwzayqa/+ZeCrum+Tr0WdhunptrrZwhayo gnfMxwWT1rbB40qlchCCJWgV+wN5AO8ttGME9i5xHxv3Tft5u0DpEBy7ji6Oo/eM8Yla k4RVwQwaz+kDUB2lp38uc9IOxpEjqzCSN1+Yq16vdPd07lqh91IG3ZnpEgHYjggqIPxs 7WIp1zY6+RlKqwUocNhrHV5AoyjRDTu2EZMvN2b+1MMqSxMOq/sk/NChMdnqT9wNoUGc 9NZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769217720; x=1769822520; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=a577FNgbL0JbRd6IsOu504RokGc/26jdmHoERsXu7xE=; b=LRYmoClQ0idoK7RNoUIGu7ZS0i4l1urlxXk03/vfVP+L54+qW+MJX9XUgZWkRGNW0p NDsfA2tfdrEyWmrOJ2aB08iQT1B8PkitkHsJTw9dQaqGawT1TKQrqMijTKGlCmHKjz/2 NKP9eO+9K3J8cexWAVnOD375DboTfF2d9YOYFg43FPAV1h66cR5zU0oFvIoIaXwRg50c e7jtbkLm8c4ucV+juAtJ6cbjjgzJGaP25O57pNmAfzG0vUfSjXu9y2u9QSz3nOqh7zQS evQHaFLpATJa3YC7bnzuBy+DRTjviDwkJpH5orrMeLXMascYLNj17TaddglnN6Hy62yu qWLg== X-Forwarded-Encrypted: i=1; AJvYcCXH6O+Kmuj33wV5RxNm3Sic8AlvXW/C7iVu4UrHFMddw+RHSkJ2qKRoBpmtVPoCmqPmr13/xEZiDeCT0UM=@vger.kernel.org X-Gm-Message-State: AOJu0YyGy4agikMN6tAIDhfpnrIztGUbZrpYZfsubCPP39tAfaD8cP8a 4aD5HuxWPkpxsFMAjSfSiqHLapImQTSlbLjcAwv8vO4HkjO54r89UUBaOnsyvbDvkSnkk7q26m6 YZfedhk0B/MGFTg== X-Received: from dlbcj34.prod.google.com ([2002:a05:7022:69a2:b0:11f:3043:2c7f]) (user=wusamuel job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7023:c081:b0:11d:fc4a:c4f7 with SMTP id a92af1059eb24-1247dba9450mr1771878c88.4.1769217720087; Fri, 23 Jan 2026 17:22:00 -0800 (PST) Date: Fri, 23 Jan 2026 17:21:29 -0800 In-Reply-To: <20260124012133.2451708-1-wusamuel@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260124012133.2451708-1-wusamuel@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260124012133.2451708-2-wusamuel@google.com> Subject: [PATCH bpf-next v3 1/3] PM: wakeup: Handle empty list in wakeup_sources_walk From: Samuel Wu To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Greg Kroah-Hartman , Danilo Krummrich , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Samuel Wu , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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(). This patch updates wakeup_sources_walk_start() to return NULL in case of an empty list. Signed-off-by: Samuel Wu --- drivers/base/power/wakeup.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index 1e1a0e7eeac5..e69033d16fba 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -275,9 +275,7 @@ EXPORT_SYMBOL_GPL(wakeup_sources_read_unlock); */ struct wakeup_source *wakeup_sources_walk_start(void) { - struct list_head *ws_head =3D &wakeup_sources; - - return list_entry_rcu(ws_head->next, struct wakeup_source, entry); + return list_first_or_null_rcu(&wakeup_sources, struct wakeup_source, entr= y); } EXPORT_SYMBOL_GPL(wakeup_sources_walk_start); =20 --=20 2.52.0.457.g6b5491de43-goog