}
}
+ /* 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;
/* 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
* 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;