diff options
author | Neil Brown <neilb@suse.de> | 2008-05-27 09:23:16 +0200 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2008-05-27 09:23:16 +0200 |
commit | 3d2b16e77caf3242162e1470371c7a21e1f50711 (patch) | |
tree | 153e63262ff1910f3ebec346aab4bc73b507c9e3 /Assemble.c | |
parent | Remove stray semicolon (diff) | |
download | mdadm-3d2b16e77caf3242162e1470371c7a21e1f50711.tar.xz mdadm-3d2b16e77caf3242162e1470371c7a21e1f50711.zip |
Avoid NULL reference calling free_super and elsewhere.
Since we made free_super a superswitch call, we need to be careful
that st is non NULL before calling st->ss->free_super(st).
Also when updating byteorder there is a chance of a similar NULL
deref.
Diffstat (limited to 'Assemble.c')
-rw-r--r-- | Assemble.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -367,7 +367,8 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, tmpdev->used = 1; loop: - tst->ss->free_super(tst); + if (tst) + tst->ss->free_super(tst); } if (mdfd < 0) { @@ -568,17 +569,18 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, devcnt++; } - if (update && strcmp(update, "byteorder")==0) - st->minor_version = 90; - if (devcnt == 0) { fprintf(stderr, Name ": no devices found for %s\n", mddev); - st->ss->free_super(st); + if (st) + st->ss->free_super(st); if (must_close) close(mdfd); return 1; } + if (update && strcmp(update, "byteorder")==0) + st->minor_version = 90; + st->ss->getinfo_super(st, &info); clean = info.array.state & 1; |