error = nvme_submit_sync_cmd(ctrl->admin_q, &c, *id, sizeof(**id));
if (error) {
dev_warn(ctrl->device, "Identify namespace failed (%d)\n", error);
- kfree(*id);
+ goto out_free_id;
}
+ error = -ENODEV;
+ if ((*id)->ncap == 0) /* namespace not allocated or attached */
+ goto out_free_id;
+ return 0;
+
+out_free_id:
+ kfree(*id);
return error;
}
if (ret)
goto out;
- if (id->ncap == 0) {
- ret = -ENODEV;
- goto free_id;
- }
-
ret = nvme_report_ns_ids(ctrl, ns->head->ns_id, id, &ids);
if (ret)
goto free_id;
if (ret)
goto out_free_queue;
- if (id->ncap == 0) /* no namespace (legacy quirk) */
- goto out_free_id;
-
ret = nvme_init_ns_head(ns, nsid, id);
if (ret)
goto out_free_id;