Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH 2/2] nvme: validate cntlid during controller initialisation
Date: Thu, 4 Apr 2019 07:26:16 +0200	[thread overview]
Message-ID: <20190404052616.GA7497@lst.de> (raw)
In-Reply-To: <20190403224158.58106-3-hare@suse.de>

> +	ret = 0;
> +	mutex_lock(&ctrl->subsys->lock);
> +	list_for_each_entry(tmp, &ctrl->subsys->ctrls, subsys_entry) {
> +		if (tmp->cntlid == ctrl->cntlid) {
> +			dev_err(ctrl->device, "Duplicate cntlid %u, rejecting\n",
> +				ctrl->cntlid);
> +			ret = -EINVAL;
> +			break;
> +		}
> +	}
> +	mutex_unlock(&ctrl->subsys->lock);

Please split the validation loop ino a separate helper.  Also I think
the check should go into nvme_init_subsystem, under the same critical
section as actualy adding the controller to the controller list to
avoid a small race window.

  reply	other threads:[~2019-04-04  5:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-03 22:41 [PATCH 0/2] nvme: validate CNTLID Hannes Reinecke
2019-04-03 22:41 ` [PATCH 1/2] nvme-multipath: avoid crash on invalid subsystem cntlid enumeration Hannes Reinecke
2019-05-03 11:04   ` Hannes Reinecke
2019-05-03 11:31     ` Christoph Hellwig
2019-04-03 22:41 ` [PATCH 2/2] nvme: validate cntlid during controller initialisation Hannes Reinecke
2019-04-04  5:26   ` Christoph Hellwig [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-05-13  6:25 detect duplicate cntlids v2 Christoph Hellwig
2019-05-13  6:25 ` [PATCH 2/2] nvme: validate cntlid during controller initialisation Christoph Hellwig
2019-05-13  6:36   ` Hannes Reinecke
2019-05-13 15:16   ` Chaitanya Kulkarni
2019-05-13 18:25   ` Heitke, Kenneth
2019-08-30 18:24   ` James Smart
2019-08-30 18:30     ` Sagi Grimberg

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=20190404052616.GA7497@lst.de \
    --to=hch@lst.de \
    /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