cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 5/5] gfs2_edit: Fix segfault in find by resource group
Date: Tue,  6 Sep 2011 13:00:17 +0100	[thread overview]
Message-ID: <1315310417-4833-5-git-send-email-anprice@redhat.com> (raw)
In-Reply-To: <1315310417-4833-1-git-send-email-anprice@redhat.com>

When using 'find' on block types which require searching by resource
group, a segfault occurs in __gfs2_next_rg_meta due to rgd->bh being
empty. This patch fixes the segfault by reading in the resource group
data, thus populating rgd->bh, prior to the search.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/edit/hexedit.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 2182704..dd0cf60 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -2056,7 +2056,7 @@ static uint64_t find_metablockoftype_slow(uint64_t startblk, int metatype, int p
 static uint64_t find_metablockoftype_rg(uint64_t startblk, int metatype, int print)
 {
 	struct osi_node *n, *next = NULL;
-	uint64_t blk;
+	uint64_t blk, errblk;
 	int first = 1, found = 0;
 	struct rgrp_tree *rgd;
 	struct gfs2_rindex *ri;
@@ -2087,6 +2087,9 @@ static uint64_t find_metablockoftype_rg(uint64_t startblk, int metatype, int pri
 	for (; !found && n; n = next){
 		next = osi_next(n);
 		rgd = (struct rgrp_tree *)n;
+		errblk = gfs2_rgrp_read(&sbd, rgd);
+		if (errblk)
+			continue;
 		first = 1;
 		do {
 			if (gfs2_next_rg_metatype(&sbd, rgd, &blk, metatype,
@@ -2098,6 +2101,7 @@ static uint64_t find_metablockoftype_rg(uint64_t startblk, int metatype, int pri
 			}
 			first = 0;
 		} while (blk <= startblk);
+		gfs2_rgrp_relse(rgd);
 	}
 	if (!found)
 		blk = 0;
-- 
1.7.6



      parent reply	other threads:[~2011-09-06 12:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-06 12:00 [Cluster-devel] [PATCH 1/5] gfs2_edit: Initialize metafds fully in savemetaopen Andrew Price
2011-09-06 12:00 ` [Cluster-devel] [PATCH 2/5] libgfs2: clean up some dead code in gfs2_writei Andrew Price
2011-09-06 12:00 ` [Cluster-devel] [PATCH 3/5] libgfs2: Remove dead code from gfs2_get_leaf Andrew Price
2011-09-06 12:00 ` [Cluster-devel] [PATCH 4/5] gfs_controld: Remove dead code from loop() Andrew Price
2011-09-06 12:43   ` Steven Whitehouse
2011-09-06 14:36   ` David Teigland
2011-09-06 12:00 ` Andrew Price [this message]

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=1315310417-4833-5-git-send-email-anprice@redhat.com \
    --to=anprice@redhat.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).