Skip to content

Commit 7a84665

Browse files
israelruChristoph Hellwig
authored andcommitted
nvmet-rdma: Fix NULL deref when setting pi_enable and traddr INADDR_ANY
When setting port traddr to INADDR_ANY, the listening cm_id->device is NULL. The associate IB device is known only when a connect request event arrives, so checking T10-PI device capability should be done at this stage. Fixes: b09160c ("nvmet-rdma: add metadata/T10-PI support") Signed-off-by: Israel Rukshin <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Max Gurtovoy <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 5342fd4 commit 7a84665

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/nvme/target/rdma.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,14 @@ nvmet_rdma_find_get_device(struct rdma_cm_id *cm_id)
12201220
}
12211221
ndev->inline_data_size = nport->inline_data_size;
12221222
ndev->inline_page_count = inline_page_count;
1223+
1224+
if (nport->pi_enable && !(cm_id->device->attrs.device_cap_flags &
1225+
IB_DEVICE_INTEGRITY_HANDOVER)) {
1226+
pr_warn("T10-PI is not supported by device %s. Disabling it\n",
1227+
cm_id->device->name);
1228+
nport->pi_enable = false;
1229+
}
1230+
12231231
ndev->device = cm_id->device;
12241232
kref_init(&ndev->ref);
12251233

@@ -1855,14 +1863,6 @@ static int nvmet_rdma_enable_port(struct nvmet_rdma_port *port)
18551863
goto out_destroy_id;
18561864
}
18571865

1858-
if (port->nport->pi_enable &&
1859-
!(cm_id->device->attrs.device_cap_flags &
1860-
IB_DEVICE_INTEGRITY_HANDOVER)) {
1861-
pr_err("T10-PI is not supported for %pISpcs\n", addr);
1862-
ret = -EINVAL;
1863-
goto out_destroy_id;
1864-
}
1865-
18661866
port->cm_id = cm_id;
18671867
return 0;
18681868

0 commit comments

Comments
 (0)