From f6bdf2820bee2b8583da3f5d9d8bd5b080ec1cd0 Mon Sep 17 00:00:00 2001 From: Tomas Mudrunka Date: Sun, 29 Dec 2024 19:55:45 +0100 Subject: [PATCH] MDRAID: Minor fixes Signed-off-by: Tomas Mudrunka --- image-mdraid.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/image-mdraid.c b/image-mdraid.c index 22e798d..fda06b1 100644 --- a/image-mdraid.c +++ b/image-mdraid.c @@ -272,7 +272,7 @@ static int mdraid_generate(struct image *image) { } static int mdraid_setup(struct image *image, cfg_t *cfg) { - if(!mdraid_time) { + if (!mdraid_time) { mdraid_time = time(NULL); srandom(mdraid_time); //For UUID generation } @@ -287,7 +287,7 @@ static int mdraid_setup(struct image *image, cfg_t *cfg) { //Find data image to be put inside the array struct image *img_in = NULL; char *src = cfg_getstr(image->imagesec, "image"); - if(src) { + if (src) { struct partition *part; part = xzalloc(sizeof *part); part->image = src; @@ -295,7 +295,11 @@ static int mdraid_setup(struct image *image, cfg_t *cfg) { if (part->image) { image_info(image, "MDRAID using data from: %s\n", part->image); - img_in = image_get(part->image); + img_in = image_get(part->image); //TODO: will this work for pre-existing images not generated by genimage??? + if (!img_in) { + image_error(image, "MDRAID cannot get image definition: %s\n", part->image); + return 8; + } if (image->size == 0) image->size = roundup(img_in->size + DATA_OFFSET_BYTES, MDRAID_ALIGN_BYTES); if (image->size < (img_in->size + DATA_OFFSET_BYTES)) {