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.
This commit is contained in:
Neil Brown 2008-05-27 17:23:16 +10:00
parent fe2979bd16
commit 3d2b16e77c
1 changed files with 7 additions and 5 deletions

View File

@ -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;