Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 1D71A1F4181 for ; Sat, 24 Jan 2026 01:22:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769217723; cv=none; b=Jjoa6NvgbemPiLdRjEgNYlTXc3yvVLinUzKMw8YvkbkAcoBUzuQFARyqWmZ4Hg1t/PTgS8lTfYWcvW/2uOPkh/rYR8PVv8feCDSqFBHJbxyncbd34UjBXcILPCK1F6OoVjUo2EAv9YWjArZLPGXmlZ1JsgAyddnWyjp5gD62pWM= 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.74 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-f74.google.com with SMTP id a92af1059eb24-1233b91de6bso4955608c88.1 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=P3TWi8p/hjU+JvLNbbEcsix1JrZYS8xs53Z0gFXlpZ1E2l/LjmAuDJTmiTV4iA75d5 1YoMBiDBpc6Eg0k3Jud5D6QwS5KQKU3ARZYLaPkMNyKbGitrLfIanSLHySgZTd00LSqV Ukzgijdv9l2jbLFUnLaOl9xuggH7W8i5+FApbh3jahRO+zoowCaAAJopB18GN8tYzFK7 YBnx9+zgrN5SSw+u0ZHxA5r0n8XqdTaJSQmAd4ID42ySANK+NraoqP5kXKZc5KDD1iD8 pCmG4qCEsbmS6Z1z/Oviibtat1JBs8g/jcY52nl/OYOJufAdfBqxqGurRZnvoo3t+EsA 27hQ== X-Forwarded-Encrypted: i=1; AJvYcCWGdJCwe+s8jpaFpCAXW1TukNqMY1l+tRdXLud8Bd7gy8q7drWno5lG4WREM60NuKCCjzJUkxA1hpiJyrctWM0=@vger.kernel.org X-Gm-Message-State: AOJu0YwBigobeyKGVYzf+SK6bzIloq7Dd82yuh8hddRmLF7QuKj19Vv/ uRkLLlpsR7545WG2hS9tw6pPJt6rbg5LXRG6sO+yhGWlpsLC98LQlAA6k6719UZJfWosLwFH3t1 FPIcB4vHIZ7hdVw== 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-kselftest@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-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 = &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); -- 2.52.0.457.g6b5491de43-goog