Neil Brown: Avoid NULL reference calling free_super and elsewhere.

Martin F. Krafft madduck at alioth.debian.org
Tue Jun 24 22:01:55 UTC 2008


Module: mdadm
Branch: upstream
Commit: 3d2b16e77caf3242162e1470371c7a21e1f50711
URL:    http://git.debian.org/?p=pkg-mdadm/mdadm.git;a=commit;h=3d2b16e77caf3242162e1470371c7a21e1f50711

Author: Neil Brown <neilb at suse.de>
Date:   Tue May 27 17:23:16 2008 +1000

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 files changed, 7 insertions(+), 5 deletions(-)

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;
 




More information about the pkg-mdadm-commits mailing list