nvme_init_ctrl() might be called from a nvme_ctrl with no
subsystem set (eg after a connect call). So ensure to
re-scan the subsystem to have it fully initialized.
Signed-off-by: Hannes Reinecke <hare@suse.de>
int nvme_init_ctrl(nvme_host_t h, nvme_ctrl_t c, int instance)
{
nvme_subsystem_t s;
- const char *subsys_name;
+ char *subsys_name = NULL;
char *path, *name;
int ret;
if (!s) {
errno = ENXIO;
ret = -1;
+ } else if (!s->name) {
+ ret = asprintf(&path, "%s/%s", nvme_subsys_sysfs_dir,
+ subsys_name);
+ if (ret > 0) {
+ ret = nvme_init_subsystem(s, subsys_name, path);
+ if (ret < 0)
+ free(path);
+ }
}
c->s = s;
list_add(&s->ctrls, &c->entry);
+ free(subsys_name);
free(name);
return ret;
}