From 3d2b16e77caf3242162e1470371c7a21e1f50711 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 27 May 2008 17:23:16 +1000 Subject: 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. --- Assemble.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Assemble.c') diff --git a/Assemble.c b/Assemble.c index 5ed2dc1..36b2304 100644 --- a/Assemble.c +++ b/Assemble.c @@ -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; -- cgit