From: minwoo.im.dev@gmail.com (Minwoo Im)
Subject: [PATCHv3 2/2] nvme: validate cntlid during controller initialisation
Date: Sat, 4 May 2019 23:20:54 +0900 [thread overview]
Message-ID: <1624cd68-f64e-d255-2f6e-5c1436699778@gmail.com> (raw)
In-Reply-To: <20190503133736.111201-3-hare@suse.de>
Hi Hannes,
I think this patch looks good. but I have a simple query here.
On 5/3/19 10:37 PM, Hannes Reinecke wrote:
> @@ -2434,10 +2452,20 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
> }
>
> mutex_lock(&subsys->lock);
> - list_add_tail(&ctrl->subsys_entry, &subsys->ctrls);
> + if (!nvme_duplicate_cntlid(subsys, ctrl))
> + list_add_tail(&ctrl->subsys_entry, &subsys->ctrls);
> + else {
> + dev_err(ctrl->device,
> + "Duplicate cntlid %u, rejecting\n",
> + ctrl->cntlid);
> + ctrl->subsys = NULL;
> + sysfs_remove_link(&subsys->dev.kobj, dev_name(ctrl->device));
> + nvme_put_subsystem(subsys);
Does it(nvme_put_subsystem()) really need to be here? I think explicit
"put" for the subsystem is always good, but right above this code, we
can see the comment when sysfs link has been failed:
if (sysfs_create_link(&subsys->dev.kobj, &ctrl->device->kobj,
dev_name(ctrl->device))) {
dev_err(ctrl->device,
"failed to create sysfs link from subsystem.\n");
/* the transport driver will eventually put the subsystem */
return -EINVAL;
}
I'm not pretty sure where the exactly the comment says, but I can see
the nvme_destroy_subsystem() would be invoked from the transport
drivers (e.g. pci, rdma, etc)
In case of nvme-pci, nvme_remove_dead_ctrl() will do the "put". For
nvme-rdma, nvme_rdma_create_ctrl() will do the "put".
Did you do just explicit "put" for the subsystem OR does it really need
to be here with any other reason?
I'm just asking why there is a difference between code above it and this
patch. If you don't mind, please let me know if I'm wrong here. :)
Thanks,
> + ret = -EINVAL;
> + }
> mutex_unlock(&subsys->lock);
>
> - return 0;
> + return ret;
>
> out_unlock:
> mutex_unlock(&nvme_subsystems_lock);
>
next prev parent reply other threads:[~2019-05-04 14:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-03 13:37 [PATCHv3 0/2] nvme: validate CNTLID Hannes Reinecke
2019-05-03 13:37 ` [PATCHv3 1/2] nvme-multipath: avoid crash on invalid subsystem cntlid enumeration Hannes Reinecke
2019-05-03 16:01 ` Keith Busch
2019-05-08 7:54 ` Christoph Hellwig
2019-05-03 13:37 ` [PATCHv3 2/2] nvme: validate cntlid during controller initialisation Hannes Reinecke
2019-05-03 16:16 ` Keith Busch
2019-05-03 19:12 ` Max Gurtovoy
2019-05-04 14:20 ` Minwoo Im [this message]
2019-05-08 7:54 ` Christoph Hellwig
2019-05-10 14:51 ` John Donnelly
2019-05-10 18:12 ` Chaitanya Kulkarni
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=1624cd68-f64e-d255-2f6e-5c1436699778@gmail.com \
--to=minwoo.im.dev@gmail.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