From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D999CC433F5 for ; Mon, 8 Nov 2021 14:07:45 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8FA50610F8 for ; Mon, 8 Nov 2021 14:07:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8FA50610F8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.223353.386016 (Exim 4.92) (envelope-from ) id 1mk5Iu-00032P-2U; Mon, 08 Nov 2021 14:07:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 223353.386016; Mon, 08 Nov 2021 14:07:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mk5It-00032I-VX; Mon, 08 Nov 2021 14:07:19 +0000 Received: by outflank-mailman (input) for mailman id 223353; Mon, 08 Nov 2021 14:07:18 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mk5Is-00032C-Fv for xen-devel@lists.xenproject.org; Mon, 08 Nov 2021 14:07:18 +0000 Received: from mail-vk1-f171.google.com (mail-vk1-f171.google.com [209.85.221.171]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2dde7282-409d-11ec-a9d2-d9f7a1cc8784; Mon, 08 Nov 2021 15:07:17 +0100 (CET) Received: by mail-vk1-f171.google.com with SMTP id bc10so8260196vkb.1 for ; Mon, 08 Nov 2021 06:07:17 -0800 (PST) Received: from mail-vk1-f175.google.com (mail-vk1-f175.google.com. [209.85.221.175]) by smtp.gmail.com with ESMTPSA id f11sm976215vkk.50.2021.11.08.06.07.14 for (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-f175.google.com with SMTP id t127so8233052vke.13 for ; Mon, 08 Nov 2021 06:07:14 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2dde7282-409d-11ec-a9d2-d9f7a1cc8784 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=GzS14cOoSvkQgT+7oyq3SzolYQ93C5ToR72Pk2OlU7XPjSvlP5nYnHbvk/SrHLKZ8O TA6f/wsj76sCk1/WrDmV9ZRSs6SqgnNMJgANshHtz1n98qGe2WCtrYOIko3oBNo3Z3bb Op9YCyfiAjn7XsLd4dxoJ3nxuMLhIZ7NJ2wNBhECZ7PlBMOLdvYFckYmL9Y/6/ha4oHc 2HWvXMv1S7Z8o8v57EIVYdK0h5YHbU+FAVPKrgIr8E5otpgB5H1JwAMBYjPcT7VtMH27 YVg5M8YSIpaSkFaWGIOsLceI0d9sHl4RIZav10Rjq6Pz1VUst4T4OeXD2H/y/Nk12VTb Gd5Q== X-Gm-Message-State: AOAM531v2LOi1Qs8vN/CYXn1PI9DJ+szBGn7d6t6kMh05ibbKiQSLYuy BKHoJtdxw3YKZnDfPCfoQ5Ln20lXWv/qolZz X-Google-Smtp-Source: ABdhPJzOmeNaSuceIBbZaZpv/a1siIsbwJIOdxhcxFSukyfj4Xqae45wnivUf7l21tGcWGdHL9REZQ== X-Received: by 2002:a05:6122:548:: with SMTP id y8mr13363304vko.24.1636380435863; Mon, 08 Nov 2021 06:07:15 -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: quoted-printable 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.c= om/ > > 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 =E2=80=98mce_register_decod= e_chain=E2=80=99: > arch/x86/kernel/cpu/mce/core.c:167:2: error: ignoring return value of \ > =E2=80=98blocking_notifier_chain_register=E2=80=99, declared with attr= ibute warn_unused_result [-Werror=3Dunused-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_not= ifier_head *nh); > > #ifdef __KERNEL__ > > -extern int atomic_notifier_chain_register(struct atomic_notifier_head *n= h, > +extern int __must_check atomic_notifier_chain_register(struct atomic_not= ifier_head *nh, > struct notifier_block *nb); > -extern int blocking_notifier_chain_register(struct blocking_notifier_hea= d *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_notifie= r_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. Bu= t when I'm talking to journalists I just say "programmer" or something like t= hat. -- Linus Torvalds