]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
fix: assemble for external metadata generates segfault if invalid device found
authorHawrylewicz Czarnowski, Przemyslaw <przemyslaw.hawrylewicz.czarnowski@intel.com>
Wed, 1 Dec 2010 00:06:09 +0000 (11:06 +1100)
committerNeilBrown <neilb@suse.de>
Wed, 1 Dec 2010 00:06:09 +0000 (11:06 +1100)
An attempt to invoke super_by_fd() on device that has
metadata_version="none" always matches super0 (as test_version is "").
In Assemble() it results in segfault when load_container is invoked
(=null for super0).
As of now load_container is only started if it points to valid pointer.

Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Assemble.c

index 5e71a434c22a312c335f4017591cd4431984b502..dc5ddd5c6af2d4d502dca5d10685a7b0d445e14b 100644 (file)
@@ -332,7 +332,8 @@ int Assemble(struct supertype *st, char *mddev,
                                        fprintf(stderr, Name ": not a recognisable container: %s\n",
                                                devname);
                                tmpdev->used = 2;
-                       } else if (tst->ss->load_container(tst, dfd, NULL)) {
+                       } else if (!tst->ss->load_container
+                                  || tst->ss->load_container(tst, dfd, NULL)) {
                                if (report_missmatch)
                                        fprintf(stderr, Name ": no correct container type: %s\n",
                                                devname);