]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-intel.c
non-trivial warn_unused_result fixes, activate_spare
[thirdparty/mdadm.git] / super-intel.c
index 7f8dd3483271796a3dd5a53381f33a6c7fbf870e..2ce398359ebd459879c0ea6decf1ce95cf1209e4 100644 (file)
@@ -1097,6 +1097,13 @@ load_imsm_disk(int fd, struct intel_super *super, char *devname, int keep_fd)
                }
        }
 
+       /* no match, maybe a stale failed drive */
+       if (i == super->anchor->num_disks && dl->index >= 0) {
+               dl->disk = *__get_imsm_disk(super->anchor, dl->index);
+               if (__le32_to_cpu(dl->disk.status) & FAILED_DISK)
+                       dl->index = -2;
+       }
+
        if (alloc)
                super->disks = dl;
 
@@ -2877,6 +2884,8 @@ static struct mdinfo *imsm_activate_spare(struct active_array *a,
  
                /* found a usable disk with enough space */
                di = malloc(sizeof(*di));
+               if (!di)
+                       continue;
                memset(di, 0, sizeof(*di));
 
                /* dl->index will be -1 in the case we are activating a
@@ -2916,7 +2925,23 @@ static struct mdinfo *imsm_activate_spare(struct active_array *a,
         * disk_ord_tbl for the array
         */
        mu = malloc(sizeof(*mu));
-       mu->buf = malloc(sizeof(struct imsm_update_activate_spare) * num_spares);
+       if (mu) {
+               mu->buf = malloc(sizeof(struct imsm_update_activate_spare) * num_spares);
+               if (mu->buf == NULL) {
+                       free(mu);
+                       mu = NULL;
+               }
+       }
+       if (!mu) {
+               while (rv) {
+                       struct mdinfo *n = rv->next;
+
+                       free(rv);
+                       rv = n;
+               }
+               return NULL;
+       }
+                       
        mu->space = NULL;
        mu->len = sizeof(struct imsm_update_activate_spare) * num_spares;
        mu->next = *updates;