public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	Christoph Hellwig <hch@infradead.org>,
	Wenchao Hao <haowenchao@huawei.com>,
	axboe@kernel.dk, jejb@linux.ibm.com, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
	martin.petersen@oracle.com,
	syzbot+f08c77040fa163a75a46@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com, linfeilong@huawei.com
Subject: Re: [PATCH] scsi: sd: call device_del() if device_add_disk() fails
Date: Thu, 31 Mar 2022 02:13:27 -0700	[thread overview]
Message-ID: <YkVwt4s+K0haRpbr@infradead.org> (raw)
In-Reply-To: <10056508.nUPlyArG6x@leap>

On Thu, Mar 31, 2022 at 11:07:45AM +0200, Fabio M. De Francesco wrote:
> If I don't misunderstand what you wrote, I think you mean something like
> the following changes:
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index a390679cf458..7a000a9a9dbe 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -3431,7 +3431,7 @@ static int sd_probe(struct device *dev)
>         sdkp->disk_dev.class = &sd_disk_class;
>         dev_set_name(&sdkp->disk_dev, "%s", dev_name(dev));
>  
> -       error = device_add(&sdkp->disk_dev);
> +       error = device_register(&sdkp->disk_dev);

The device_initialize call about also need to go.

>         if (error) {
>                 put_device(&sdkp->disk_dev);

.. and this put_device

>                 goto out;
> @@ -3474,7 +3474,7 @@ static int sd_probe(struct device *dev)
>  
>         error = device_add_disk(dev, gd, NULL);
>         if (error) {
> -               put_device(&sdkp->disk_dev);
> +               device_unregister(&sdkp->disk_dev);
>                 goto out;
>         }

.. and then the cleanup patch would need the same logic.  But thinking
about it I don't think we actually can do that due to the split
unregistration.  So I take my suggestion back.

  reply	other threads:[~2022-03-31  9:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 15:49 [PATCH] scsi: sd: call device_del() if device_add_disk() fails Fabio M. De Francesco
2022-03-30  4:30 ` Dan Carpenter
2022-03-31 15:26 ` Wenchao Hao
2022-03-31  5:41   ` Dan Carpenter
2022-03-31  5:45     ` Christoph Hellwig
2022-03-31  9:07       ` Fabio M. De Francesco
2022-03-31  9:13         ` Christoph Hellwig [this message]
2022-03-31 10:13           ` Fabio M. De Francesco
2022-03-31 12:14     ` Wenchao Hao
2022-03-31 13:42       ` Dan Carpenter
2022-03-31 14:19         ` James Bottomley
2022-03-31 15:11           ` Dan Carpenter
2022-03-31 16:14         ` Fabio M. De Francesco
2022-03-31 16:24           ` Dan Carpenter
2022-03-31 17:21             ` Fabio M. De Francesco

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=YkVwt4s+K0haRpbr@infradead.org \
    --to=hch@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=dan.carpenter@oracle.com \
    --cc=fmdefrancesco@gmail.com \
    --cc=haowenchao@huawei.com \
    --cc=jejb@linux.ibm.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=syzbot+f08c77040fa163a75a46@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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