From 417f346ee0cc59607a236fd4db8c79dee0825fb1 Mon Sep 17 00:00:00 2001 From: "Hawrylewicz Czarnowski, Przemyslaw" Date: Wed, 1 Dec 2010 11:06:09 +1100 Subject: [PATCH] fix: assemble for external metadata generates segfault if invalid device found 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 Signed-off-by: NeilBrown --- Assemble.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Assemble.c b/Assemble.c index 5e71a434..dc5ddd5c 100644 --- a/Assemble.c +++ b/Assemble.c @@ -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); -- 2.47.2