summaryrefslogtreecommitdiffstats
path: root/super-ddf.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2008-09-28 12:12:08 -0700
committerDan Williams <dan.j.williams@intel.com>2008-10-15 14:15:52 -0700
commit792449393d1792e1bdb45aedada395f345564484 (patch)
treeb894fce7ddd71e709e1fe120c548749e4cff743d /super-ddf.c
parent175593bf286d3593e3690b3b321388b24663910f (diff)
downloadmdadm-792449393d1792e1bdb45aedada395f345564484.tar.gz
mdadm-792449393d1792e1bdb45aedada395f345564484.tar.xz
mdadm-792449393d1792e1bdb45aedada395f345564484.zip
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>
Diffstat (limited to 'super-ddf.c')
-rw-r--r--super-ddf.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/super-ddf.c b/super-ddf.c
index 81f8b01..527e326 100644
--- a/super-ddf.c
+++ b/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);