linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Adam Kwolek <adam.kwolek@intel.com>
Cc: linux-raid@vger.kernel.org, ed.ciechanowski@intel.com,
	marcin.labun@intel.com, dan.j.williams@intel.com
Subject: Re: [PATCH 1/4] FIX: restore_backup() throws core dump
Date: Wed, 5 Oct 2011 13:30:36 +1100	[thread overview]
Message-ID: <20111005133036.2107c993@notabene.brown> (raw)
In-Reply-To: <20111003161338.18410.79083.stgit@gklab-128-013.igk.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1462 bytes --]

On Mon, 03 Oct 2011 18:13:38 +0200 Adam Kwolek <adam.kwolek@intel.com> 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@suse.de>
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@intel.com>
    Signed-off-by: NeilBrown <neilb@suse.de>

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

  reply	other threads:[~2011-10-05  2:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-03 16:13 [PATCH 0/4] Fix freezing multiple arrays in container during assembly (2) Adam Kwolek
2011-10-03 16:13 ` [PATCH 1/4] FIX: restore_backup() throws core dump Adam Kwolek
2011-10-05  2:30   ` NeilBrown [this message]
2011-10-03 16:13 ` [PATCH 2/4] Add recovery blocked field to mdinfo Adam Kwolek
2011-10-03 16:13 ` [PATCH 3/4] imsm: Fill recovery_blocked field present in mdinfo Adam Kwolek
2011-10-03 16:14 ` [PATCH 4/4] Remove freeze() call from Grow_continue() Adam Kwolek
2011-10-05  2:34 ` [PATCH 0/4] Fix freezing multiple arrays in container during assembly (2) NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111005133036.2107c993@notabene.brown \
    --to=neilb@suse.de \
    --cc=adam.kwolek@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ed.ciechanowski@intel.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=marcin.labun@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).