bdev/nvme: assign names to hot-inserted devices.
this patch fix the potential possibility of coredump when we have NVMe device hot inserted. Change-Id: Idac255f25f42b4746c2d3ae6dfc57a19b7001160 Signed-off-by: Cunyin Chang <cunyin.chang@intel.com>
This commit is contained in:
parent
0488fd84b8
commit
e5b62c126a
@ -111,6 +111,7 @@ struct nvme_probe_ctx {
|
||||
const char *names[NVME_MAX_CONTROLLERS];
|
||||
};
|
||||
|
||||
static int g_hot_insert_nvme_controller_index = 0;
|
||||
static int g_reset_controller_on_timeout = 0;
|
||||
static int g_timeout = 0;
|
||||
static int g_nvme_adminq_poll_timeout_us = 0;
|
||||
@ -580,13 +581,16 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
|
||||
const char *name = NULL;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < ctx->count; i++) {
|
||||
if (spdk_nvme_transport_id_compare(trid, &ctx->trids[i]) == 0) {
|
||||
name = strdup(ctx->names[i]);
|
||||
break;
|
||||
if (ctx) {
|
||||
for (i = 0; i < ctx->count; i++) {
|
||||
if (spdk_nvme_transport_id_compare(trid, &ctx->trids[i]) == 0) {
|
||||
name = strdup(ctx->names[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
name = spdk_sprintf_alloc("HotInsertNvme%d", g_hot_insert_nvme_controller_index);
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
SPDK_ERRLOG("Failed to assign name to NVMe device\n");
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user