Skip to content

Commit 75ef7b8

Browse files
committed
Merge tag 'nvme-6.16-2025-07-03' of git://git.infradead.org/nvme into block-6.16
Pull NVMe fixes from Christoph: "- fix incorrect cdw15 value in passthru error logging (Alok Tiwari) - fix memory leak of bio integrity in nvmet (Dmitry Bogdanov) - refresh visible attrs after being checked (Eugen Hristev) - fix suspicious RCU usage warning in the multipath code (Geliang Tang) - correctly account for namespace head reference counter (Nilay Shroff)" * tag 'nvme-6.16-2025-07-03' of git://git.infradead.org/nvme: nvme-multipath: fix suspicious RCU usage warning nvme-pci: refresh visible attrs after being checked nvmet: fix memory leak of bio integrity nvme: correctly account for namespace head reference counter nvme: Fix incorrect cdw15 value in passthru error logging
2 parents 0d519bb + d681107 commit 75ef7b8

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

drivers/nvme/host/core.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ static void nvme_log_err_passthru(struct request *req)
386386
nr->cmd->common.cdw12,
387387
nr->cmd->common.cdw13,
388388
nr->cmd->common.cdw14,
389-
nr->cmd->common.cdw14);
389+
nr->cmd->common.cdw15);
390390
}
391391

392392
enum nvme_disposition {
@@ -4086,6 +4086,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
40864086
struct nvme_ns *ns;
40874087
struct gendisk *disk;
40884088
int node = ctrl->numa_node;
4089+
bool last_path = false;
40894090

40904091
ns = kzalloc_node(sizeof(*ns), GFP_KERNEL, node);
40914092
if (!ns)
@@ -4178,9 +4179,22 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
41784179
out_unlink_ns:
41794180
mutex_lock(&ctrl->subsys->lock);
41804181
list_del_rcu(&ns->siblings);
4181-
if (list_empty(&ns->head->list))
4182+
if (list_empty(&ns->head->list)) {
41824183
list_del_init(&ns->head->entry);
4184+
/*
4185+
* If multipath is not configured, we still create a namespace
4186+
* head (nshead), but head->disk is not initialized in that
4187+
* case. As a result, only a single reference to nshead is held
4188+
* (via kref_init()) when it is created. Therefore, ensure that
4189+
* we do not release the reference to nshead twice if head->disk
4190+
* is not present.
4191+
*/
4192+
if (ns->head->disk)
4193+
last_path = true;
4194+
}
41834195
mutex_unlock(&ctrl->subsys->lock);
4196+
if (last_path)
4197+
nvme_put_ns_head(ns->head);
41844198
nvme_put_ns_head(ns->head);
41854199
out_cleanup_disk:
41864200
put_disk(disk);

drivers/nvme/host/multipath.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,8 @@ static void nvme_remove_head(struct nvme_ns_head *head)
690690
nvme_cdev_del(&head->cdev, &head->cdev_device);
691691
synchronize_srcu(&head->srcu);
692692
del_gendisk(head->disk);
693-
nvme_put_ns_head(head);
694693
}
694+
nvme_put_ns_head(head);
695695
}
696696

697697
static void nvme_remove_head_work(struct work_struct *work)
@@ -1200,7 +1200,8 @@ void nvme_mpath_add_sysfs_link(struct nvme_ns_head *head)
12001200
*/
12011201
srcu_idx = srcu_read_lock(&head->srcu);
12021202

1203-
list_for_each_entry_rcu(ns, &head->list, siblings) {
1203+
list_for_each_entry_srcu(ns, &head->list, siblings,
1204+
srcu_read_lock_held(&head->srcu)) {
12041205
/*
12051206
* Ensure that ns path disk node is already added otherwise we
12061207
* may get invalid kobj name for target
@@ -1291,6 +1292,9 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head)
12911292
{
12921293
bool remove = false;
12931294

1295+
if (!head->disk)
1296+
return;
1297+
12941298
mutex_lock(&head->subsys->lock);
12951299
/*
12961300
* We are called when all paths have been removed, and at that point

drivers/nvme/host/pci.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,8 +2101,6 @@ static void nvme_map_cmb(struct nvme_dev *dev)
21012101
if ((dev->cmbsz & (NVME_CMBSZ_WDS | NVME_CMBSZ_RDS)) ==
21022102
(NVME_CMBSZ_WDS | NVME_CMBSZ_RDS))
21032103
pci_p2pmem_publish(pdev, true);
2104-
2105-
nvme_update_attrs(dev);
21062104
}
21072105

21082106
static int nvme_set_host_mem(struct nvme_dev *dev, u32 bits)
@@ -3010,6 +3008,8 @@ static void nvme_reset_work(struct work_struct *work)
30103008
if (result < 0)
30113009
goto out;
30123010

3011+
nvme_update_attrs(dev);
3012+
30133013
result = nvme_setup_io_queues(dev);
30143014
if (result)
30153015
goto out;
@@ -3343,6 +3343,8 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
33433343
if (result < 0)
33443344
goto out_disable;
33453345

3346+
nvme_update_attrs(dev);
3347+
33463348
result = nvme_setup_io_queues(dev);
33473349
if (result)
33483350
goto out_disable;

drivers/nvme/target/nvmet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,8 @@ static inline void nvmet_req_bio_put(struct nvmet_req *req, struct bio *bio)
867867
{
868868
if (bio != &req->b.inline_bio)
869869
bio_put(bio);
870+
else
871+
bio_uninit(bio);
870872
}
871873

872874
#ifdef CONFIG_NVME_TARGET_TCP_TLS

0 commit comments

Comments
 (0)