Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp6448221pxb; Mon, 8 Nov 2021 08:47:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTLFnp83teFWOLCRNXGpAAImfn548/efMmD69hOGNO7M/WCXZfesae8lQ38AyAtKcosjw3 X-Received: by 2002:a17:906:17d5:: with SMTP id u21mr832088eje.16.1636390020962; Mon, 08 Nov 2021 08:47:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636390020; cv=none; d=google.com; s=arc-20160816; b=ukRAogj7mz7NkL5OO5co/aKKS6yaNm/m6CIZtrMgZAZKp6rmjp7w4IrgWLohzJ0M/q AP4gvGSe5dQ848+cnhJKDRc2Hol9/hV4x+1ucV7cYy8RGIY4uEhuLYMZWG9AtrhEig6u tCgBeWe2B/zFixu0loi2qUzqe6YtmgPi/Ua3yiV6aH5f1C8vaRG/AprX260T79eyU+Xf XkEoJ+HANb3Snd/B6ug3ESSNAYXgfQq8kjK1B64PAXu/Uwo9IsWkcOBnspiqvwy7/m3Z rBQzM7m1BK56dBZcr4T3c5boI0C6HvrsOv6onsV2RSeiH6/XQJ080A9fsnOTQq+w57H7 fZoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=MzAqGh8/DQDcYt7rjPYykgJtmHtBi2jnvuXji9J2xZw=; b=LJDmFfHXjPFwnchet2KlwdGjnTMONIoPnGKR92UqDstVrilYvcnd4WaEY3+mMYIcCG pPKayqNyMMTlhA/NjBjPJ4RhsGrK2qFQE++dLUVzngjskqCbHLEcUv9RT9nGSr7Z7Qlf oUygiNrDwzZgB7RcznMLbjnVrvyWgyHjZehyl+IxKx8xeXz7o6fzuWETgkx+qxLBiwc5 ieDOZtuTN4j5PgYyaLM206gTFTflGNIvIAk0S2IgdE8Ic5vu97Dl6nsfeUbMkeognyYO k8Uj7i0/oZ4ZbfyTxc2YpuNzLqZII/eq7On/rye3fqumZd51Q4s8sGLa3xtJsdkJ/OEx Qn+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sd2si34594760ejc.122.2021.11.08.08.45.56; Mon, 08 Nov 2021 08:47:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240248AbhKHOKG convert rfc822-to-8bit (ORCPT + 99 others); Mon, 8 Nov 2021 09:10:06 -0500 Received: from mail-ua1-f54.google.com ([209.85.222.54]:34507 "EHLO mail-ua1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240246AbhKHOKC (ORCPT ); Mon, 8 Nov 2021 09:10:02 -0500 Received: by mail-ua1-f54.google.com with SMTP id b3so31739471uam.1; Mon, 08 Nov 2021 06:07:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=srssYsTsVb5ivMDmTAt6Y7lXgP/lHHGiJX97jzZpFII=; b=lT7Q627YXwAYYti9TyWmhNrAwxF37ER+DnnHvi8ZOaxozyOw/rwlQ66wlApkNuyNN0 l/36WyzNYJX7UwsJU1aMV3bW5Sz7j/IP33Z/kZbh3aJA6GtHX+o7tNp9p+l7GF4QkKIB sjbbINID3WCsCkZrFWfMUwfrp9PjYh6onoNzXUnoEQ/95F5HYU5n5UHmTstBfe0urn4h 1SE5gPNj3Pc2mvjTTyE8StQTFs4/Z7quYn3ZeZl33bFkXJAPxUlQqv23fQ05cU4PyTMU am1ot2b90FgHRA4kFfiBdu8fFSdh6YxyoBpITiqz4ORJJJdFb9hLqYTU1fxm5MWEErbR 0b5Q== X-Gm-Message-State: AOAM531VcfMwSWKNLwI/Nir0vc2ScGiGBGnffpEeKxm2KOJGi6tJeJ4f ZdyVgO2KwEjymrO3gMZbXCXik2FZgi7ZJAl7 X-Received: by 2002:ab0:3e3:: with SMTP id 90mr185644uau.102.1636380435783; Mon, 08 Nov 2021 06:07:15 -0800 (PST) Received: from mail-vk1-f171.google.com (mail-vk1-f171.google.com. [209.85.221.171]) by smtp.gmail.com with ESMTPSA id c11sm3226781vsh.22.2021.11.08.06.07.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Nov 2021 06:07:14 -0800 (PST) Received: by mail-vk1-f171.google.com with SMTP id a129so8254621vkb.8; Mon, 08 Nov 2021 06:07:14 -0800 (PST) X-Received: by 2002:a05:6122:1350:: with SMTP id f16mr21288847vkp.26.1636380434409; Mon, 08 Nov 2021 06:07:14 -0800 (PST) MIME-Version: 1.0 References: <20211108101157.15189-1-bp@alien8.de> <20211108101157.15189-43-bp@alien8.de> In-Reply-To: <20211108101157.15189-43-bp@alien8.de> From: Geert Uytterhoeven Date: Mon, 8 Nov 2021 15:07:03 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v0 42/42] notifier: Return an error when callback is already registered To: Borislav Petkov Cc: LKML , Thomas Gleixner , Arnd Bergmann , Ayush Sawal , Greg Kroah-Hartman , Rohit Maheshwari , Steven Rostedt , Vinay Kumar Yadav , ALSA Development Mailing List , bcm-kernel-feedback-list , Intel Graphics Development , intel-gvt-dev@lists.freedesktop.org, alpha , Linux ARM , linux-clk , Linux Crypto Mailing List , linux-edac@vger.kernel.org, Linux Fbdev development list , linux-hyperv@vger.kernel.org, linux-iio@vger.kernel.org, linux-leds , "open list:BROADCOM NVRAM DRIVER" , Parisc List , Linux PM list , linuxppc-dev , "open list:REMOTE PROCESSOR (REMOTEPROC) SUBSYSTEM" , Linux-Renesas , linux-s390 , scsi , Linux-sh list , linux-staging@lists.linux.dev, linux-tegra , linux-um , USB list , "open list:TENSILICA XTENSA PORT (xtensa)" , netdev , openipmi-developer@lists.sourceforge.net, rcu@vger.kernel.org, sparclinux , "the arch/x86 maintainers" , xen-devel@lists.xenproject.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi Borislav, On Mon, Nov 8, 2021 at 11:13 AM Borislav Petkov wrote: > From: Borislav Petkov > > The notifier registration routine doesn't return a proper error value > when a callback has already been registered, leading people to track > whether that registration has happened at the call site: > > https://lore.kernel.org/amd-gfx/20210512013058.6827-1-mukul.joshi@amd.com/ > > Which is unnecessary. > > Return -EEXIST to signal that case so that callers can act accordingly. > Enforce callers to check the return value, leading to loud screaming > during build: > > arch/x86/kernel/cpu/mce/core.c: In function ‘mce_register_decode_chain’: > arch/x86/kernel/cpu/mce/core.c:167:2: error: ignoring return value of \ > ‘blocking_notifier_chain_register’, declared with attribute warn_unused_result [-Werror=unused-result] > blocking_notifier_chain_register(&x86_mce_decoder_chain, nb); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Drop the WARN too, while at it. > > Suggested-by: Thomas Gleixner > Signed-off-by: Borislav Petkov Thanks for your patch! > --- a/include/linux/notifier.h > +++ b/include/linux/notifier.h > @@ -141,13 +141,13 @@ extern void srcu_init_notifier_head(struct srcu_notifier_head *nh); > > #ifdef __KERNEL__ > > -extern int atomic_notifier_chain_register(struct atomic_notifier_head *nh, > +extern int __must_check atomic_notifier_chain_register(struct atomic_notifier_head *nh, > struct notifier_block *nb); > -extern int blocking_notifier_chain_register(struct blocking_notifier_head *nh, > +extern int __must_check blocking_notifier_chain_register(struct blocking_notifier_head *nh, > struct notifier_block *nb); > -extern int raw_notifier_chain_register(struct raw_notifier_head *nh, > +extern int __must_check raw_notifier_chain_register(struct raw_notifier_head *nh, > struct notifier_block *nb); > -extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh, > +extern int __must_check srcu_notifier_chain_register(struct srcu_notifier_head *nh, > struct notifier_block *nb); I think the addition of __must_check is overkill, leading to the addition of useless error checks and message printing. Many callers call this where it cannot fail, and where nothing can be done in the very unlikely event that the call would ever start to fail. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds