From patchwork Mon Nov 8 10:11:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 12608165 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 671ADC433EF for ; Mon, 8 Nov 2021 10:15:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 3A82E611C4 for ; Mon, 8 Nov 2021 10:15:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3A82E611C4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=alien8.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oiwca35MBEcC3EajQ/G3nNmr/LB1yWzdiw4ScaEPOKs=; b=Q76nLax8X9K9Ik c8LXf8OgzQ38JMMFlNu9prRGMzzJ7Fnhzn5wsWbq7L3S3nunlZKLR8TUQIOxiB84LSg1HPuxmO4go JhCC2AJ29SkqCkOyu9WI28yxwb8it0UUEQHe0diF9g066ppzbA4tBxf5+e86f3xWHzc64LjDgl/XU o/y6ihM44US/s9AQnRTXdUSheMdPj3Mj35agnpei4uAY9IoGOy7PkP79iUAq2/BFcwoTDTEyWdQZl D0MxLYs55oKEfXLhldokpZJ1FNt69wOfDLp7HiHI3Wrrb5Ezdtw6dNNl7RTTBtspZcbhhW7T46OVM dWSSYm/ZsYKws8Ljy+GQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mk1da-00Fyuw-9s; Mon, 08 Nov 2021 10:12:26 +0000 Received: from mail.skyhub.de ([5.9.137.197]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mk1dV-00Fyrj-FI for linux-arm-kernel@lists.infradead.org; Mon, 08 Nov 2021 10:12:23 +0000 Received: from zn.tnic (p200300ec2f33110088892b77bd117736.dip0.t-ipconnect.de [IPv6:2003:ec:2f33:1100:8889:2b77:bd11:7736]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id EBC641EC04E0; Mon, 8 Nov 2021 11:12:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1636366333; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X/Hn91jrBnlYF021LHj4jTZZybHLn5KSnhf9Ef7LdEA=; b=NeAoIcmaCi5Z+Dgahdru8ptYYODaoo3vHiVvX3JjxGdyJLE2lL5nZiug0IvwERk4pJyiyz DymQsesyzS5+7+pvdQJHNFtxPaQer5MNWCfkXyqTsrToIJE0DU0z+7IT4DbxKby/q3oOjt XmxxjoiyIcrB5gPDpC2rm/04gA32vLw= From: Borislav Petkov To: LKML Cc: linux-arm-kernel@lists.infradead.org Subject: [PATCH v0 06/42] firmware: Check notifier registration return value Date: Mon, 8 Nov 2021 11:11:21 +0100 Message-Id: <20211108101157.15189-7-bp@alien8.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211108101157.15189-1-bp@alien8.de> References: <20211108101157.15189-1-bp@alien8.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211108_021221_690998_07E6CB36 X-CRM114-Status: GOOD ( 12.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Borislav Petkov Avoid homegrown notifier registration checks. No functional changes. Signed-off-by: Borislav Petkov Cc: linux-arm-kernel@lists.infradead.org --- drivers/firmware/arm_scmi/notify.c | 3 ++- drivers/firmware/google/gsmi.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c index 0efd20cd9d69..f4c42ac00c63 100644 --- a/drivers/firmware/arm_scmi/notify.c +++ b/drivers/firmware/arm_scmi/notify.c @@ -1358,7 +1358,8 @@ static int scmi_notifier_register(const struct scmi_handle *handle, if (!hndl) return -EINVAL; - blocking_notifier_chain_register(&hndl->chain, nb); + if (blocking_notifier_chain_register(&hndl->chain, nb)) + pr_warn("SCMI notifier already registered\n"); /* Enable events for not pending handlers */ if (!IS_HNDL_PENDING(hndl)) { diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c index adaa492c3d2d..a658e7c106c3 100644 --- a/drivers/firmware/google/gsmi.c +++ b/drivers/firmware/google/gsmi.c @@ -1030,8 +1030,10 @@ static __init int gsmi_init(void) register_reboot_notifier(&gsmi_reboot_notifier); register_die_notifier(&gsmi_die_notifier); - atomic_notifier_chain_register(&panic_notifier_list, - &gsmi_panic_notifier); + + if (atomic_notifier_chain_register(&panic_notifier_list, + &gsmi_panic_notifier)) + pr_warn("gsmi panic notifier already registered\n"); printk(KERN_INFO "gsmi version " DRIVER_VERSION " loaded\n"); From patchwork Mon Nov 8 10:11:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 12608163 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 2D889C433F5 for ; Mon, 8 Nov 2021 10:15:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E9FC761207 for ; Mon, 8 Nov 2021 10:15:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E9FC761207 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=alien8.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=n5V8ne4tu0DHTh+9g4K4kskNVahEeFnV71H38a2t+ns=; b=i/pALXBGgWmTPo CC8BQSQTentGGIpAJwHlWB+tcFA8SCCNGqQgbRXDuD/IeMlxf0eGY6fBkD96s445DbkSaTxY6ScUn MdtC0nfcSoBjmDF/NBaNT8K2H8Jvg0GfLWpqp8nM7+tVjkeFqROahrn9wHCLcHwoi6MXWyya2QdgG A/HCFRL8ynjG74eZUhTQh1MCI3YwZ4XAcPvmvTvXppbl+Q6Q5fZcGXY2PDEMHvCYZkGRsYLpT/rrU 9hpel/katwFCjIvlorIbUlUdb+JhgKTfwDYpnMug6MaQ7f6EzBThortkEsF1xwWViIZQQ0Uj958o4 iKw7laRBX3h0FNumUNlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mk1dk-00FyxO-KL; Mon, 08 Nov 2021 10:12:36 +0000 Received: from mail.skyhub.de ([2a01:4f8:190:11c2::b:1457]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mk1dg-00FywL-HR for linux-arm-kernel@lists.infradead.org; Mon, 08 Nov 2021 10:12:33 +0000 Received: from zn.tnic (p200300ec2f33110088892b77bd117736.dip0.t-ipconnect.de [IPv6:2003:ec:2f33:1100:8889:2b77:bd11:7736]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 117821EC051F; Mon, 8 Nov 2021 11:12:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1636366351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZrcRCvECKj7IKUT0HhuHkcjgG9gjdsthfkW1xcjqiQQ=; b=Bry7kjH/QPnC8+/1Xd35kNkpMnozd5dqVjBxpEJhFQos8IwQXvKbX5GfwlRbJOwjjNWHuN cy1YdUgsC+vuiCb5tv2y4EgPfGNdUovYo7RznunEwaImVg/xycVcfO6RgLRcz+j5NLy4aZ ttYPmlYm9OJYwZrmbpqI/hS5S/0F8RQ= From: Borislav Petkov To: LKML Cc: linux-arm-kernel@lists.infradead.org Subject: [PATCH v0 29/42] arm64: Check notifier registration return value Date: Mon, 8 Nov 2021 11:11:44 +0100 Message-Id: <20211108101157.15189-30-bp@alien8.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211108101157.15189-1-bp@alien8.de> References: <20211108101157.15189-1-bp@alien8.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211108_021232_760405_AF4F33C4 X-CRM114-Status: GOOD ( 12.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Borislav Petkov Avoid homegrown notifier registration checks. No functional changes. Signed-off-by: Borislav Petkov Cc: linux-arm-kernel@lists.infradead.org --- arch/arm64/kernel/setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index be5f85b0a24d..e66af9de7cd7 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -440,8 +440,10 @@ static struct notifier_block arm64_panic_block = { static int __init register_arm64_panic_block(void) { - atomic_notifier_chain_register(&panic_notifier_list, - &arm64_panic_block); + if (atomic_notifier_chain_register(&panic_notifier_list, + &arm64_panic_block)) + pr_warn("Panic notifier already registered\n"); + return 0; } device_initcall(register_arm64_panic_block); From patchwork Mon Nov 8 10:11:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 12608167 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 00B6FC433F5 for ; Mon, 8 Nov 2021 10:15:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C3E5A61207 for ; Mon, 8 Nov 2021 10:15:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C3E5A61207 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=alien8.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9DbxP/23BlVg0InQoFBoNLw1jt41S6Hj00IGtsVY2t4=; b=4Ou7hd7EOCgN7n 3bEr02neHpdeI/lzKt1meHP2yhTS93moTP9tb6k3x8h8gRnYs/cv+ct8dWROBM62yrOFfGf9cfem+ uwA0NIdMXF8gElQxpo/Gk3+UJvNxY+LZ/C7T98rODb1wdIsikhggu8UoofVkWqwbBg3WW2XBv1Yqx Ni+RkcsJIAefcDJ13qJEfCGS7TYsF2NqjdB4sgKyeSmBHIXUwrwqetISomAGIUJiMp95FUiY2QxZm TgM9J9dLmk34Jg8jdLiJ94PyQMAF60Pl+1rvkamRivjvzcS2BJJIpM4eEToFgzoU3eN6NoTC5IWyn CDSJEApratnHTFzclxcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mk1dx-00Fz0p-4Q; Mon, 08 Nov 2021 10:12:49 +0000 Received: from mail.skyhub.de ([5.9.137.197]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mk1dr-00FyzQ-6l; Mon, 08 Nov 2021 10:12:45 +0000 Received: from zn.tnic (p200300ec2f33110088892b77bd117736.dip0.t-ipconnect.de [IPv6:2003:ec:2f33:1100:8889:2b77:bd11:7736]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 97BC51EC0535; Mon, 8 Nov 2021 11:12:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1636366361; h=from:from: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=ZSl40zXDlt+0/rSkoDA+/axSBICuEw4xrW9t+JeAzRg=; b=O9utTH7kzvF0ogbSAjrVux8Q2NyGvuXt2DXX+lXMfGwQDD5NsnAlA7vS1HO+tdNI+F2ntn CZwfQStJuxv3i5Q66Ie7iUHTOBEhoA6pq6felnVAUxHBDq6LlMPMTRyA2hQo7p+FfRiqlX omkNlvF2ej63UhZNrO1CmPB0HckLABU= From: Borislav Petkov To: LKML Cc: Thomas Gleixner , Arnd Bergmann , Ayush Sawal , Greg Kroah-Hartman , Rohit Maheshwari , Steven Rostedt , Vinay Kumar Yadav , alsa-devel@alsa-project.org, bcm-kernel-feedback-list@broadcom.com, intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-crypto@vger.kernel.org, linux-edac@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-iio@vger.kernel.org, linux-leds@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-remoteproc@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-sh@vger.kernel.org, linux-staging@lists.linux.dev, linux-tegra@vger.kernel.org, linux-um@lists.infradead.org, linux-usb@vger.kernel.org, linux-xtensa@linux-xtensa.org, netdev@vger.kernel.org, openipmi-developer@lists.sourceforge.net, rcu@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org, xen-devel@lists.xenproject.org Subject: [PATCH v0 42/42] notifier: Return an error when callback is already registered Date: Mon, 8 Nov 2021 11:11:57 +0100 Message-Id: <20211108101157.15189-43-bp@alien8.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211108101157.15189-1-bp@alien8.de> References: <20211108101157.15189-1-bp@alien8.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211108_021243_437644_19B8E7E3 X-CRM114-Status: GOOD ( 17.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Cc: Arnd Bergmann Cc: Ayush Sawal Cc: Greg Kroah-Hartman Cc: Rohit Maheshwari Cc: Steven Rostedt Cc: Vinay Kumar Yadav Cc: alsa-devel@alsa-project.org Cc: bcm-kernel-feedback-list@broadcom.com Cc: intel-gfx@lists.freedesktop.org Cc: intel-gvt-dev@lists.freedesktop.org Cc: linux-alpha@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-clk@vger.kernel.org Cc: linux-crypto@vger.kernel.org Cc: linux-edac@vger.kernel.org Cc: linux-fbdev@vger.kernel.org Cc: linux-hyperv@vger.kernel.org Cc: linux-iio@vger.kernel.org Cc: linux-leds@vger.kernel.org Cc: linux-mips@vger.kernel.org Cc: linux-parisc@vger.kernel.org Cc: linux-pm@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-remoteproc@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org Cc: linux-s390@vger.kernel.org Cc: linux-scsi@vger.kernel.org Cc: linux-sh@vger.kernel.org Cc: linux-staging@lists.linux.dev Cc: linux-tegra@vger.kernel.org Cc: linux-um@lists.infradead.org Cc: linux-usb@vger.kernel.org Cc: linux-xtensa@linux-xtensa.org Cc: netdev@vger.kernel.org Cc: openipmi-developer@lists.sourceforge.net Cc: rcu@vger.kernel.org Cc: sparclinux@vger.kernel.org Cc: x86@kernel.org Cc: xen-devel@lists.xenproject.org --- include/linux/notifier.h | 8 ++++---- kernel/notifier.c | 36 +++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/include/linux/notifier.h b/include/linux/notifier.h index 87069b8459af..45cc5a8d0fd8 100644 --- 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); extern int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh, diff --git a/kernel/notifier.c b/kernel/notifier.c index b8251dc0bc0f..451ef3f73ad2 100644 --- a/kernel/notifier.c +++ b/kernel/notifier.c @@ -20,13 +20,11 @@ BLOCKING_NOTIFIER_HEAD(reboot_notifier_list); */ static int notifier_chain_register(struct notifier_block **nl, - struct notifier_block *n) + struct notifier_block *n) { while ((*nl) != NULL) { - if (unlikely((*nl) == n)) { - WARN(1, "double register detected"); - return 0; - } + if (unlikely((*nl) == n)) + return -EEXIST; if (n->priority > (*nl)->priority) break; nl = &((*nl)->next); @@ -134,10 +132,11 @@ static int notifier_call_chain_robust(struct notifier_block **nl, * * Adds a notifier to an atomic notifier chain. * - * Currently always returns zero. + * Returns 0 on success, %-EEXIST on error. */ -int atomic_notifier_chain_register(struct atomic_notifier_head *nh, - struct notifier_block *n) +int __must_check +atomic_notifier_chain_register(struct atomic_notifier_head *nh, + struct notifier_block *n) { unsigned long flags; int ret; @@ -216,10 +215,11 @@ NOKPROBE_SYMBOL(atomic_notifier_call_chain); * Adds a notifier to a blocking notifier chain. * Must be called in process context. * - * Currently always returns zero. + * Returns 0 on success, %-EEXIST on error. */ -int blocking_notifier_chain_register(struct blocking_notifier_head *nh, - struct notifier_block *n) +int __must_check +blocking_notifier_chain_register(struct blocking_notifier_head *nh, + struct notifier_block *n) { int ret; @@ -335,10 +335,11 @@ EXPORT_SYMBOL_GPL(blocking_notifier_call_chain); * Adds a notifier to a raw notifier chain. * All locking must be provided by the caller. * - * Currently always returns zero. + * Returns 0 on success, %-EEXIST on error. */ -int raw_notifier_chain_register(struct raw_notifier_head *nh, - struct notifier_block *n) +int __must_check +raw_notifier_chain_register(struct raw_notifier_head *nh, + struct notifier_block *n) { return notifier_chain_register(&nh->head, n); } @@ -406,10 +407,11 @@ EXPORT_SYMBOL_GPL(raw_notifier_call_chain); * Adds a notifier to an SRCU notifier chain. * Must be called in process context. * - * Currently always returns zero. + * Returns 0 on success, %-EEXIST on error. */ -int srcu_notifier_chain_register(struct srcu_notifier_head *nh, - struct notifier_block *n) +int __must_check +srcu_notifier_chain_register(struct srcu_notifier_head *nh, + struct notifier_block *n) { int ret;