Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4449578pxb; Mon, 27 Sep 2021 18:00:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLkgepHjwMfVhaw1WPd+KgoAmwKAv5hKoecs3rsTZppufGRfQS2LOJbJf43ElivoOp2Dq0 X-Received: by 2002:a17:907:a425:: with SMTP id sg37mr3696252ejc.131.1632790854447; Mon, 27 Sep 2021 18:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632790854; cv=none; d=google.com; s=arc-20160816; b=d2zwnnSQiT+FZlzUeSNO1Teycy8LwLfySuyCSl8fLXnEqn+CPcgmAEY89053NiNgsU mWbbhdvPPXHxFe16s7mDZiEqM2kcVihO8aqqPPHzEeZPGjFwzVosBX+RWyKv6YwbF1RU ebr4XQ3Ha7kR5RcCMMCx172KsNB57iETJTXWNUQshBIDMs+1nk97+7+gzKhftwT8y7wG LL4YxFAkSUCcMH9s0DIM4w66xVbg8BglDU5In6QbA7qNq7i38SMtzofHaYrodRRE0Eau Oa5EwgNkJZc0+/8aeUdMAlpBlYxP8PmydqNDChYumxF8M6V/5b4Cb/G8ncHejccgr/Qm BEUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=aMTOwy1kRDglv9bWeV4pQeESYMtX8UBlRbYC0yXYRgQ=; b=DUklbRb6LO+ZbfrEZ2LKwS+EH+ewtpyta1OnGCpVQkJTfL1/km7pirlQYCZLUM4QCS TSLI4+QH2Ik8clj+ePwLC+pCJ3z9qhSZyQzY6UsZ9SezboKX8Bf2+eRACzQcTcC9aEu4 6RlJJJIrWyYBhw3fU7rGFzFh70RlaOcpzV3Y1Dx4IxdHng7GKCLNoqLHOggh/yak3XYg 5TVoikTvNIUmd0nXud7OSJUIExxVKxnDmKkBlWLRkbkRQOG4qpurZ4TAxi/E3Z8FtGGh 1RQq98K2MDuLcgAZewBhY8KpR0J3+G53p9VCzmKH795mC6ZCrPsy5OfHG/w+j5UGlYQn 8fZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=ZOuzWiff; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 g19si10406167ejm.44.2021.09.27.18.00.30; Mon, 27 Sep 2021 18:00:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=ZOuzWiff; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238482AbhI1A7B (ORCPT + 99 others); Mon, 27 Sep 2021 20:59:01 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:54075 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238379AbhI1A7A (ORCPT ); Mon, 27 Sep 2021 20:59:00 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 5A767580410; Mon, 27 Sep 2021 20:57:21 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 27 Sep 2021 20:57:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=aMTOwy 1kRDglv9bWeV4pQeESYMtX8UBlRbYC0yXYRgQ=; b=ZOuzWiffGLc+sX04l19gVI YY7DB3F4UXso43esbO2BFAmGjtbUBmJrMhgHl4Fd4/lP1389NVGKiry/eU8DymQu 1YWx0FyxfMdNGl2+hMg3S1+BYOoPXz0iuv+o/CabL6FncacKte1kSmv/QFcq2FHn 1xi7LMekdnXTfgame6h/F8oo74ECuK5k1aubF5xuZ+D21osluDhHLH8s4hp7uJb5 PhhKkWS703MBMpMsGFLvfMibC9pyeZZVFcs75aEy8IAzwOw2I44j+Ud3S+iIaSrp GjrX7GClyfWkWUEWAciNfw1iX0TwKthVfI2IoF/0ITpk+1cbfK2eeCRtmXkLhQbA == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejledgfeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvufgjkfhfgggtsehttdertd dttddvnecuhfhrohhmpefhihhnnhcuvfhhrghinhcuoehfthhhrghinheslhhinhhugidq mheikehkrdhorhhgqeenucggtffrrghtthgvrhhnpeffudfhgeefvdeitedugfelueeghe ekkeefveffhfeiveetledvhfdtveffteeuudenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehfthhhrghinheslhhinhhugidqmheikehkrdhorh hg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 27 Sep 2021 20:57:18 -0400 (EDT) Date: Tue, 28 Sep 2021 10:57:18 +1000 (AEST) From: Finn Thain To: Luis Chamberlain cc: axboe@kernel.dk, hch@lst.de, efremov@linux.com, song@kernel.org, jejb@linux.ibm.com, martin.petersen@oracle.com, viro@zeniv.linux.org.uk, hare@suse.de, jack@suse.cz, ming.lei@redhat.com, tj@kernel.org, linux-raid@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Tetsuo Handa Subject: Re: [PATCH v2 1/2] block: make __register_blkdev() return an error In-Reply-To: <20210927220332.1074647-2-mcgrof@kernel.org> Message-ID: <2ac2e05f-327a-b66f-aaa0-276db2e46730@linux-m68k.org> References: <20210927220332.1074647-1-mcgrof@kernel.org> <20210927220332.1074647-2-mcgrof@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 27 Sep 2021, Luis Chamberlain wrote: > diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c > index 5dc9b3d32415..be0627345b21 100644 > --- a/drivers/block/ataflop.c > +++ b/drivers/block/ataflop.c > @@ -1989,24 +1989,34 @@ static int ataflop_alloc_disk(unsigned int drive, unsigned int type) > > static DEFINE_MUTEX(ataflop_probe_lock); > > -static void ataflop_probe(dev_t dev) > +static int ataflop_probe(dev_t dev) > { > int drive = MINOR(dev) & 3; > int type = MINOR(dev) >> 2; > + int err = 0; > > if (type) > type--; > > - if (drive >= FD_MAX_UNITS || type >= NUM_DISK_MINORS) > - return; > + if (drive >= FD_MAX_UNITS || type >= NUM_DISK_MINORS) { > + err = -EINVAL; > + goto out; > + } > + > mutex_lock(&ataflop_probe_lock); > if (!unit[drive].disk[type]) { > - if (ataflop_alloc_disk(drive, type) == 0) { > - add_disk(unit[drive].disk[type]); > + err = ataflop_alloc_disk(drive, type); > + if (err == 0) { > + err = add_disk(unit[drive].disk[type]); > + if (err) > + blk_cleanup_disk(unit[drive].disk[type]); > unit[drive].registered[type] = true; > } > } > mutex_unlock(&ataflop_probe_lock); > + > +out: > + return err; > } > > static void atari_cleanup_floppy_disk(struct atari_floppy_struct *fs) I think the change to ataflop_probe() would be more clear without adding an 'out' label, like your change to floppy.c: > diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c > index 0434f28742e7..95a1c8ef62f7 100644 > --- a/drivers/block/floppy.c > +++ b/drivers/block/floppy.c > @@ -4517,21 +4517,27 @@ static int floppy_alloc_disk(unsigned int drive, unsigned int type) > > static DEFINE_MUTEX(floppy_probe_lock); > > -static void floppy_probe(dev_t dev) > +static int floppy_probe(dev_t dev) > { > unsigned int drive = (MINOR(dev) & 3) | ((MINOR(dev) & 0x80) >> 5); > unsigned int type = (MINOR(dev) >> 2) & 0x1f; > + int err = 0; > > if (drive >= N_DRIVE || !floppy_available(drive) || > type >= ARRAY_SIZE(floppy_type)) > - return; > + return -EINVAL; > > mutex_lock(&floppy_probe_lock); > if (!disks[drive][type]) { > - if (floppy_alloc_disk(drive, type) == 0) > - add_disk(disks[drive][type]); > + if (floppy_alloc_disk(drive, type) == 0) { > + err = add_disk(disks[drive][type]); > + if (err) > + blk_cleanup_disk(disks[drive][type]); > + } > } > mutex_unlock(&floppy_probe_lock); > + > + return err; > } > > static int __init do_floppy_init(void) In floppy_probe(), I think you should return the potential error result from floppy_alloc_disk(), like you did in ataflop.c.