From nobody Mon Jun 8 08:46:59 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCD4748BD26; Wed, 3 Jun 2026 14:25:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780496713; cv=none; b=TOAazAMoUpiPQKIfm5LEFatgBXpUqjaHjWgl4wxhRN+vFYe0msxWpOUqEhejGMOMBn7DZlgdwFWZmxVHn9JLBXWS+2TE8HuaJVjaAuP+LGdEZoz5fPHj7ggUE4KnNVep2rqETjcbR+mTnbbg6mcWipj63EqgiFar1oY9kZETi58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780496713; c=relaxed/simple; bh=ypyHfYj9On4XedeMKS8H2oy2Gg68IW0fyVXbp4hED4U=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=p+/4savXedkCGLEbmUzmBGEpn9k63gQXeERkpMP15I3DvldebU+O/3T3K8PIUekz8M2tbUCwCG0uSIqYJlyBDnOqa34pm79oAnPbETHai0iTfSK1rG30B004YttH8yD5yiwDdXcp3CR8987Lr0N94wphA0urWjHQH+Kfbmr8VoQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=3sscySmk; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=FCX2w4H0; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3sscySmk"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FCX2w4H0" Date: Wed, 03 Jun 2026 14:25:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780496710; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4XDZQox6kEw6/k16bHiv9BI1rFSTpP15Lxo/2FD21QI=; b=3sscySmkI8ynWkW0EpMNr3ySMrbRG5zuCTxxtnIFmSyi1whgxjhN0BxZShInsXOMDFnkmj RwJO42OnIyWU8rlAGMS8T2xqdggJyTs5w50fNKRsGqG02rWpynGMKk1shsTBal+c96JjDL v6TJybtm5dd5mO8i7pWtn4NEUhUIwxPbXmOOIkg4yXEJmPPVZy+EY0gQ2hLIXubgBVUic3 QJkr3kDQRHkErdue+cIMxv7EKYg6y2vduSFl+rRFprjnRgc8QCkenxHzC7MXCj5eQOwE/s O4WiCw1kcxBpuznaKOQd0CfyfR4mOz/J+9HqkXkgAPlO2yMxk1pN8RW131xvpQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780496710; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4XDZQox6kEw6/k16bHiv9BI1rFSTpP15Lxo/2FD21QI=; b=FCX2w4H05GqI7pq4qWG9gJw8J634LNoVo3WIF3ntTwA+DSP2l4lJOTZzKFYdWVcBUDf8VZ vQKJlNrCSLOklwDg== From: "tip-bot2 for Dmitry Ilvokhin" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] cleanup: Annotate guard constructors with nonnull Cc: Dmitry Ilvokhin , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <85fee12eec20abfcf711443518e8f0caec982a86.1780064327.git.d@ilvokhin.com> References: <85fee12eec20abfcf711443518e8f0caec982a86.1780064327.git.d@ilvokhin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178049670913.710.11313057492737534540.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the locking/core branch of tip: Commit-ID: 22302af28d3f7c3ca38536978c80db51d2a9e283 Gitweb: https://git.kernel.org/tip/22302af28d3f7c3ca38536978c80db51d= 2a9e283 Author: Dmitry Ilvokhin AuthorDate: Tue, 02 Jun 2026 07:12:52=20 Committer: Peter Zijlstra CommitterDate: Wed, 03 Jun 2026 11:38:48 +02:00 cleanup: Annotate guard constructors with nonnull Add __nonnull_args() to unconditional guard constructors so the compiler warns when NULL is statically known to be passed: - DEFINE_GUARD(): re-declare the constructor with __nonnull_args(). - __DEFINE_LOCK_GUARD_1(): annotate the constructor directly. DEFINE_LOCK_GUARD_0() needs no annotation: its constructor takes no pointer arguments (.lock is hardcoded to (void *)1). Define the __nonnull_args() macro in compiler_attributes.h, following the existing convention for attribute wrappers. Deliberately not named '__nonnull', to avoid clashing with glibc's __nonnull() when kernel and userspace headers are combined (User Mode Linux for example). Signed-off-by: Dmitry Ilvokhin Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/85fee12eec20abfcf711443518e8f0caec982a86.178= 0064327.git.d@ilvokhin.com --- include/linux/cleanup.h | 4 +++- include/linux/compiler_attributes.h | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/linux/cleanup.h b/include/linux/cleanup.h index ea95ca4..4e60d51 100644 --- a/include/linux/cleanup.h +++ b/include/linux/cleanup.h @@ -397,6 +397,7 @@ static __maybe_unused const bool class_##_name##_is_con= ditional =3D _is_cond __DEFINE_GUARD_LOCK_PTR(_name, _T) =20 #define DEFINE_GUARD(_name, _type, _lock, _unlock) \ + static __always_inline __nonnull_args() _type class_##_name##_constructor= (_type _T); \ DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type = _T); \ DEFINE_CLASS_IS_GUARD(_name) =20 @@ -497,7 +498,8 @@ static __always_inline void class_##_name##_destructor(= class_##_name##_t *_T) \ __DEFINE_GUARD_LOCK_PTR(_name, &_T->lock) =20 #define __DEFINE_LOCK_GUARD_1(_name, _type, ...) \ -static __always_inline class_##_name##_t class_##_name##_constructor(_type= *l) \ +static __always_inline __nonnull_args() \ +class_##_name##_t class_##_name##_constructor(_type *l) \ __no_context_analysis \ { \ class_##_name##_t _t =3D { .lock =3D l }, *_T =3D &_t; \ diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_a= ttributes.h index c16d419..cffe093 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -231,6 +231,15 @@ #define noinline __attribute__((__noinline__)) =20 /* + * Note: deliberately not named '__nonnull', to avoid clashing with glibc's + * __nonnull() when kernel and userspace headers are combined. + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-= nonnull + * clang: https://clang.llvm.org/docs/AttributeReference.html#nonnull + */ +#define __nonnull_args(x...) __attribute__((__nonnull__(x))) + +/* * Optional: only supported since gcc >=3D 8 * Optional: not supported by clang *