[PATCH] FIX: Seg Fault in incremental if BBM log detected

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bug  detected for imsm metadata.
Assembling of array using Incremental switch generate segmentation
fault if BBM log is detected.
Reason: missing return from Incremental_container if BBM is detected
and unnecessary list=NULL assignment.
This patch fix the problem and memory leak in this area.

Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@xxxxxxxxx>
---
 Incremental.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/Incremental.c b/Incremental.c
index 889184f..26739fe 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -1471,7 +1471,19 @@ static int Incremental_container(struct supertype *st, char *devname,
 	if (list->array.state & (1<<MD_SB_BBM_ERRORS)) {
 		fprintf(stderr, Name ": BBM log found in metadata. "
 					"Cannot activate array(s).\n");
-		list = NULL;
+		/* free container data and exit */
+		while (list) {
+			struct mdinfo *d1 = list->next;
+			struct mdinfo *disk = list->devs;
+			while (disk) {
+				struct mdinfo *d2 = disk->next;
+				free(disk);
+				disk = d2;
+			}
+			free(list);
+			list = d1;
+		}
+		return 2;
 	}
 
 	for (ra = list ; ra ; ra = ra->next) {

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux