Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2308361pxb; Sun, 17 Oct 2021 11:08:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYjpzzqZ11bVVTzM76n2XeZ32E+rcONzXgQxvIDjbqzfFCUZkjuQ/bBLNojBIlZAVjJk65 X-Received: by 2002:a63:7447:: with SMTP id e7mr19466386pgn.261.1634494133715; Sun, 17 Oct 2021 11:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634494133; cv=none; d=google.com; s=arc-20160816; b=he61dXnMn2+vDP9Uylv9u1piLV9ADZ1YqDH/Vu6QiG7za16AmjMyqXp3acIq/Ys877 Q5XZNH98XCMUicmI1EKfOAZgJao9n2KmrSIH5rNQfVWmDtsrcPUbXoh6g9P9otbS2No8 1Lt/tKDvIAm7j8QKy/o5LJx0T2LSNeJdNoTwIuKWI47dUMdPPmDMJh4NY7tJsgnUtIZV 3syBAMH73PuoZ898mYt8wwfTK9C+2G3B/yUFUoR0hpRnu8jEvcwtA6PaPChABiTGpEyq R1e5kxcNskWw/32oraKnAEtKB7x8qx9myy7EEK+Isw281kdpaIxgyZQ7/FH4AnUl/+l+ E0PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=CrScqNKMgRV1rKvxe0whCx/+ah432GRzJ6rU4W802Bg=; b=LC6XrJZKVD0YIjmd81qCPnQLKDdiusyi/Ol3LBrVumb4vBQCXcS5kme6QHps1NcuTC JjalF24FdK1OPyTFK5GfUqtoYj2vhDvSmZ/UDWlutNxmD6k5Qz4CblVW/BE/tkZgvMTE QE5QFg2q/8ydHzVtnrs2vgfRDhVbmGhMTn4/gGhuo9vjnxwWie+cquu3ttCvVLvCQUh+ M5XWGnjGgoqx8/yGseJ4HCcpSB8mOfGuQuaZs6WQDUht60yBRu5g8CzlqhSSCGsX7vUC cJD/QR4vO85QF7re0x+rAojj3f2B/q7K30T4gIYSpQbcMQR2djfvWE+749GSVnVl9pR5 B9iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=e8yUBc7V; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j14si24307049pjf.142.2021.10.17.11.08.41; Sun, 17 Oct 2021 11:08:53 -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=@infradead.org header.s=bombadil.20210309 header.b=e8yUBc7V; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241501AbhJOSpm (ORCPT + 99 others); Fri, 15 Oct 2021 14:45:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241405AbhJOSpd (ORCPT ); Fri, 15 Oct 2021 14:45:33 -0400 Received: from bombadil.infradead.org (unknown [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E19CC061570; Fri, 15 Oct 2021 11:43:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CrScqNKMgRV1rKvxe0whCx/+ah432GRzJ6rU4W802Bg=; b=e8yUBc7VImD8hMVZvoak5LZiI0 XuCa4kRJ/sMe0/AKP6Y7pUNQlINfWnpN48qy1UcXov5eBZRHO42yaD7EiJ8GfcsupZTucc7gp4uCI RLRoYivgL3qydgIg9R0ydVOVNVoiooG2WZrbzU+52LgTABMGTysGTfVTuhhL/13yiC4IDQlEPOWoq CFYEiCaUApfdlh4TZ3+gP7/ylAPPxxuF1xvYQ9Zs5PKvWttP8FrzuwGgkHyYsqTKzRe6SSMeqN+qg 03/46Fc11IfcngA7KSMUqv2x56TGi1o6PrzyiD4dLVRZSA4p7HU5f4IbPzDZ8+8W+C7GMQdtF8E4D pc7XbnUw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbSAn-008U2u-6D; Fri, 15 Oct 2021 18:43:17 +0000 Date: Fri, 15 Oct 2021 11:43:17 -0700 From: Luis Chamberlain To: Finn Thain 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 Message-ID: References: <20210927220332.1074647-1-mcgrof@kernel.org> <20210927220332.1074647-2-mcgrof@kernel.org> <2ac2e05f-327a-b66f-aaa0-276db2e46730@linux-m68k.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2ac2e05f-327a-b66f-aaa0-276db2e46730@linux-m68k.org> Sender: Luis Chamberlain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 28, 2021 at 10:57:18AM +1000, Finn Thain wrote: > 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: Good point! Fixed. > > 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. Indeed, thanks, fixed. Luis