linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: axboe@kernel.dk, hch@lst.de, penguin-kernel@i-love.sakura.ne.jp,
	dan.j.williams@intel.com, vishal.l.verma@intel.com,
	dave.jiang@intel.com, ira.weiny@intel.com, richard@nod.at,
	miquel.raynal@bootlin.com, vigneshr@ti.com, efremov@linux.com,
	song@kernel.org, martin.petersen@oracle.com, hare@suse.de,
	jack@suse.cz, ming.lei@redhat.com, tj@kernel.org,
	linux-mtd@lists.infradead.org, linux-scsi@vger.kernel.org,
	linux-raid@vger.kernel.org, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/4] ataflop: address add_disk() error handling on probe
Date: Wed, 3 Nov 2021 19:20:16 +0100	[thread overview]
Message-ID: <20211103182016.GB7745@lst.de> (raw)
In-Reply-To: <20211103181258.1462704-3-mcgrof@kernel.org>

On Wed, Nov 03, 2021 at 11:12:56AM -0700, Luis Chamberlain wrote:
> We need to cleanup resources on the probe() callback registered
> with __register_blkdev(), now that add_disk() error handling is
> supported. Address this.
> 
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> ---
>  drivers/block/ataflop.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
> index 170dd193cef6..e981b351f37e 100644
> --- a/drivers/block/ataflop.c
> +++ b/drivers/block/ataflop.c
> @@ -2012,6 +2012,7 @@ static void ataflop_probe(dev_t dev)
>  {
>  	int drive = MINOR(dev) & 3;
>  	int type  = MINOR(dev) >> 2;
> +	int err = 0;
>  
>  	if (type)
>  		type--;
> @@ -2019,11 +2020,20 @@ static void ataflop_probe(dev_t dev)
>  	if (drive >= FD_MAX_UNITS || type >= NUM_DISK_MINORS)
>  		return;
>  	if (!unit[drive].disk[type]) {
> +		err = ataflop_alloc_disk(drive, type);
> +		if (err == 0) {
> +			err = add_disk(unit[drive].disk[type]);
> +			if (err)
> +				goto err_out;
> +			else
> +				unit[drive].registered[type] = true;

This looks weird.  Why not:

 	if (unit[drive].disk[type])
		return;

	if (ataflop_alloc_disk(drive, type))
		return;
	if (add_disk(unit[drive].disk[type]))
		goto cleanup_disk;
	unit[drive].registered[type] = true;
	return;

cleanup_disk:
	blk_cleanup_disk(unit[drive].disk[type]);
	unit[drive].disk[type] = NULL;

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2021-11-03 18:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 18:12 [PATCH v4 0/4] last set for add_disk() error handling Luis Chamberlain
2021-11-03 18:12 ` [PATCH v4 1/4] block: update __register_blkdev() probe documentation Luis Chamberlain
2021-11-03 18:18   ` Christoph Hellwig
2021-11-03 18:12 ` [PATCH v4 2/4] ataflop: address add_disk() error handling on probe Luis Chamberlain
2021-11-03 18:20   ` Christoph Hellwig [this message]
2021-11-03 18:21     ` Christoph Hellwig
2021-11-03 18:12 ` [PATCH v4 3/4] floppy: " Luis Chamberlain
2021-11-03 18:20   ` Christoph Hellwig
2021-11-03 18:12 ` [PATCH v4 4/4] block: add __must_check for *add_disk*() callers Luis Chamberlain
2021-11-03 18:20   ` Christoph Hellwig
2021-11-03 19:28 ` [PATCH v4 0/4] last set for add_disk() error handling Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211103182016.GB7745@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=efremov@linux.com \
    --cc=hare@suse.de \
    --cc=ira.weiny@intel.com \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mcgrof@kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=richard@nod.at \
    --cc=song@kernel.org \
    --cc=tj@kernel.org \
    --cc=vigneshr@ti.com \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).