diff options
author | Mateusz Grzonka <mateusz.grzonka@intel.com> | 2022-06-13 11:59:34 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2022-06-14 16:41:42 +0200 |
commit | 626bc45396c4959f2c4685c2faa7c4f553f4efdf (patch) | |
tree | 44cea41771402fc64ffd2280e95d786d64ed3b1b /super-ddf.c | |
parent | Mdmonitor: Improve logging method (diff) | |
download | mdadm-626bc45396c4959f2c4685c2faa7c4f553f4efdf.tar.xz mdadm-626bc45396c4959f2c4685c2faa7c4f553f4efdf.zip |
Fix possible NULL ptr dereferences and memory leaks
In Assemble there was a NULL check for sra variable,
which effectively didn't stop the execution in every case.
That might have resulted in a NULL pointer dereference.
Also in super-ddf, mu variable was set to NULL for some condition,
and then immidiately dereferenced.
Additionally some memory wasn't freed as well.
Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'super-ddf.c')
-rw-r--r-- | super-ddf.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/super-ddf.c b/super-ddf.c index 8cda23a7..abbc8b09 100644 --- a/super-ddf.c +++ b/super-ddf.c @@ -5125,13 +5125,16 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a, */ vc = find_vdcr(ddf, a->info.container_member, rv->disk.raid_disk, &n_bvd, &vcl); - if (vc == NULL) + if (vc == NULL) { + free(rv); return NULL; + } mu = xmalloc(sizeof(*mu)); if (posix_memalign(&mu->space, 512, sizeof(struct vcl)) != 0) { free(mu); - mu = NULL; + free(rv); + return NULL; } mu->len = ddf->conf_rec_len * 512 * vcl->conf.sec_elmnt_count; @@ -5161,6 +5164,8 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a, pr_err("BUG: can't find disk %d (%d/%d)\n", di->disk.raid_disk, di->disk.major, di->disk.minor); + free(mu); + free(rv); return NULL; } vc->phys_refnum[i_prim] = ddf->phys->entries[dl->pdnum].refnum; |