non-trivial warn_unused_result fixes, activate_spare
Both super-ddf and super-intel ignore memory allocation failures during ->activate_spare. Fix these up by cancelling the activation. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
175593bf28
commit
792449393d
17
super-ddf.c
17
super-ddf.c
|
@ -3287,6 +3287,8 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a,
|
|||
|
||||
/* Cool, we have a device with some space at pos */
|
||||
di = malloc(sizeof(*di));
|
||||
if (!di)
|
||||
continue;
|
||||
memset(di, 0, sizeof(*di));
|
||||
di->disk.number = i;
|
||||
di->disk.raid_disk = i;
|
||||
|
@ -3319,8 +3321,21 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a,
|
|||
* phys_refnum and lba_offset values
|
||||
*/
|
||||
mu = malloc(sizeof(*mu));
|
||||
if (mu && posix_memalign(&mu->space, 512, sizeof(struct vcl)) != 0) {
|
||||
free(mu);
|
||||
mu = NULL;
|
||||
}
|
||||
if (!mu) {
|
||||
while (rv) {
|
||||
struct mdinfo *n = rv->next;
|
||||
|
||||
free(rv);
|
||||
rv = n;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mu->buf = malloc(ddf->conf_rec_len * 512);
|
||||
posix_memalign(&mu->space, 512, sizeof(struct vcl));
|
||||
mu->len = ddf->conf_rec_len;
|
||||
mu->next = *updates;
|
||||
vc = find_vdcr(ddf, a->info.container_member);
|
||||
|
|
|
@ -2884,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
|
||||
|
@ -2923,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;
|
||||
|
|
Loading…
Reference in New Issue