Re: [PATCH 1/4] FIX: restore_backup() throws core dump

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

 



On Mon, 03 Oct 2011 18:13:38 +0200 Adam Kwolek <adam.kwolek@xxxxxxxxx> wrote:

> 1. restore_backup() throws core dump during releasing fdlist.
> Loop for closing handlers checks next_spare variable,
> but iterates disk_count.

The best way to fix this is simply to just fix this.. See below.

> 
> 2. fdlist initialization/close is corrected to initialize/close
>    whole allocated array

This is unnecessary.

> 
> 3. next_spare variable name is replaced by spares

But the variable doesn't contain a count of the number of spares.  It contains
the number of the next spare...

NeilBrown

commit cc7f63e55319b5c372af20ce528e7e7230746d92
Author: NeilBrown <neilb@xxxxxxx>
Date:   Wed Oct 5 13:29:16 2011 +1100

    restore_backup() throws core dump
    
    restore_backup() throws core dump during releasing fdlist.
    Loop for closing handlers checks next_spare variable,
    but iterates disk_count.
    
    Reported-by: Adam Kwolek <adam.kwolek@xxxxxxxxx>
    Signed-off-by: NeilBrown <neilb@xxxxxxx>

diff --git a/Grow.c b/Grow.c
index de177d8..9fa2d6b 100644
--- a/Grow.c
+++ b/Grow.c
@@ -78,9 +78,9 @@ int restore_backup(struct supertype *st,
 				   backup_file, verbose > 0);
 
 	while (next_spare > 0) {
-		disk_count--;
-		if (fdlist[disk_count] >= 0)
-			close(fdlist[disk_count]);
+		next_spare--;
+		if (fdlist[next_spare] >= 0)
+			close(fdlist[next_spare]);
 	}
 	free(fdlist);
 	if (err) {

Attachment: signature.asc
Description: PGP signature


[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