static void nvme_mpath_set_live(struct nvme_ns *ns)
 {
        struct nvme_ns_head *head = ns->head;
+       int rc;
 
        if (!head->disk)
                return;
 
+       /*
+        * test_and_set_bit() is used because it is protecting against two nvme
+        * paths simultaneously calling device_add_disk() on the same namespace
+        * head.
+        */
        if (!test_and_set_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) {
-               device_add_disk(&head->subsys->dev, head->disk,
-                               nvme_ns_id_attr_groups);
+               rc = device_add_disk(&head->subsys->dev, head->disk,
+                                    nvme_ns_id_attr_groups);
+               if (rc) {
+                       clear_bit(NVME_NSHEAD_DISK_LIVE, &ns->flags);
+                       return;
+               }
                nvme_add_ns_head_cdev(head);
        }