Skip to contentSkip to conversation

nvme-core: don't initlialize ctrl->cntlid twice

PATCH Applied Andrey Smirnov 4 participants 4 messages Jan 8, 2019 – Jan 9, 2019 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme-core: don't initlialize ctrl->cntlid twice

ctrl->cntlid will already be initialized from id->cntlid for non-NVME_F_FABRICS controllers few lines below. For NVME_F_FABRICS controllers this field should already be initialized, otherwise the check

	if (ctrl->cntlid != le16_to_cpu(id->cntlid))

below will always be a no-op.

Cc Keith Busch <keith.busch at intel.com>
Cc Jens Axboe <axboe at fb.com>
Cc Christoph Hellwig <hch at lst.de>
Cc Sagi Grimberg <sagi at grimberg.me>
Cc linux-nvme at lists.infradead.org
Cc linux-kernel at vger.kernel.org
Signed-off-by Andrey Smirnov <andrew.smirnov at gmail.com>

---

I created this patch just from readying NVMe code. Appologies for the noise if I misread/misinterpreted things and this assignment is actually necessary.

Thanks,
Andrey Smirnov

 drivers/nvme/host/core.c | 1 -
 1 file changed, 1 deletion(-)
drivers/nvme/host/core.c +0 -1
index 2e65be8b1387..1ec87b30fad1 100644
@@ -2397,7 +2397,6 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
 	ctrl->oaes = le32_to_cpu(id->oaes);
 	atomic_set(&ctrl->abort_limit, id->acl + 1);
 	ctrl->vwc = id->vwc;
-	ctrl->cntlid = le16_to_cpup(&id->cntlid);
 	if (id->mdts)
 		max_hw_sectors = 1 << (id->mdts + page_shift - 9);
 	else
Signature · 1 line
2.20.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Reviewed-by Sagi Grimberg <sagi at grimberg.me>
Reviewed-by on v1 1/1
#2 lore raw
In reply to Andrey Smirnov
Quoted 8 lines · Andrey Smirnov

ctrl->cntlid will already be initialized from id->cntlid for non-NVME_F_FABRICS controllers few lines below. For NVME_F_FABRICS controllers this field should already be initialized, otherwise the check

	if (ctrl->cntlid != le16_to_cpu(id->cntlid))

below will always be a no-op.

Yeah, this bug defeats the fabrics sanity check. Good catch.

Reviewed-by Keith Busch <keith.busch at intel.com>
Quoted 13 lines
drivers/nvme/host/core.c +0 -1
index 2e65be8b1387..1ec87b30fad1 100644
@@ -2397,7 +2397,6 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
 	ctrl->oaes = le32_to_cpu(id->oaes);
 	atomic_set(&ctrl->abort_limit, id->acl + 1);
 	ctrl->vwc = id->vwc;
-	ctrl->cntlid = le16_to_cpup(&id->cntlid);
 	if (id->mdts)
 		max_hw_sectors = 1 << (id->mdts + page_shift - 9);
 	else