Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp479744pxb; Mon, 8 Nov 2021 17:03:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYLMTJNnkw8kCZG1UZfxxzEk5kKSzAuSDPO+/5hE0rBTzkXcaCYjqATH49ToAW8TXkFgV5 X-Received: by 2002:a05:6e02:1a0a:: with SMTP id s10mr2424225ild.161.1636419803409; Mon, 08 Nov 2021 17:03:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636419803; cv=none; d=google.com; s=arc-20160816; b=smdAKHwPmzV0XXdIYazlNxrDhCfU3eSMntRHqeNFHnTNGn4tDw3jU5w9QZUWuwPpIs k+ZtPd/+1p3+7sIkh1upkGxDVITiZgoYgbW9Fcz5EnixDYaXAEDgmTPtqqecoB6nuObi si8WA1WA8T77+vgkmAWBNhKoX1TiBsI0lbZ44TuN25yJBYLOCDw2qzh9c9VZNny9EGEt bp59xD22Y3tFHq2DFcAim9OhnKQZGXqCz89McDosQHkEGtma28ilci9kLv2y7rIgprkt gJIbRJtb3jiM+G1mHyYrJ6LSC5aaUAcODv7vmVa/p37ZnUEfHd1hSCbOEPtGSdfnC4KC WlbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=M4a2QhX42ro5DFg7OVx53Z18MObzJp7U5I459Z/HVYg=; b=NXfh6wJMWk69tSkwvSfHyPmcFa9Hor3Ur45IDtw/0RuNXp+04K2IU+tzI6uDROW7Rk wivV55MRZ3ZNBZepynPn+ja7OLJqpuDzKfaNng8LEx2OGQNK/ooNiisNqbf6srLgwLze YWcXw5YKdNtKj24E7QJ263HKxa0ugkVATtpcQ0xs3MjAwTU7rheQz1xuWFpby15WZUQa ypHaC11/sYsOi8wXlUBw81MGHVK2txdbr/exdTlJRg+7L55odFuvFYL4a1wcs1ipyUwP 2K/nKGOw1TKmbzhn+/A7uIEiqVoVqv+BmlLy/gqxMAbIO/GFGC3mZ/vgTMBPbR2bfwsR GFNg== 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 y17si36338251iow.62.2021.11.08.17.02.18; Mon, 08 Nov 2021 17:03:23 -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 S238369AbhKHVCO (ORCPT + 99 others); Mon, 8 Nov 2021 16:02:14 -0500 Received: from netrider.rowland.org ([192.131.102.5]:54331 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S236371AbhKHVCM (ORCPT ); Mon, 8 Nov 2021 16:02:12 -0500 Received: (qmail 1679175 invoked by uid 1000); 8 Nov 2021 15:59:26 -0500 Date: Mon, 8 Nov 2021 15:59:26 -0500 From: Alan Stern To: Borislav Petkov Cc: Geert Uytterhoeven , 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 Subject: Re: [PATCH v0 42/42] notifier: Return an error when callback is already registered Message-ID: <20211108205926.GA1678880@rowland.harvard.edu> References: <20211108101157.15189-1-bp@alien8.de> <20211108101157.15189-43-bp@alien8.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Nov 08, 2021 at 05:21:45PM +0100, Borislav Petkov wrote: > On Mon, Nov 08, 2021 at 05:12:16PM +0100, Geert Uytterhoeven wrote: > > Returning void is the other extreme ;-) > > > > There are 3 levels (ignoring BUG_ON()/panic () inside the callee): > > 1. Return void: no one can check success or failure, > > 2. Return an error code: up to the caller to decide, > > 3. Return a __must_check error code: every caller must check. > > > > I'm in favor of 2, as there are several places where it cannot fail. > > Makes sense to me. I'll do that in the next iteration. Is there really any reason for returning an error code? For example, is it anticipated that at some point in the future these registration calls might fail? Currently, the only reason for failing to register a notifier callback is because the callback is already registered. In a sense this isn't even an actual failure -- after the registration returns the callback _will_ still be registered. So if the call can never really fail, why bother with a return code? Especially since the caller can't do anything with such a code value. Given the current state of affairs, I vote in favor of 1 (plus a WARN or something similar to generate a stack dump in the callee, since double registration really is a bug). Alan Stern