Gitweb:
http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitd...
Commit: 3b0d981b18e1d9c0126c80b14af2c922fe841465
Parent: 8d9c74306165491098c07dc19b79b6f2f9b9cc62
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Sep 6 12:40:38 2011 +0100
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Tue Sep 6 13:51:51 2011 +0100
gfs2_edit: Fix segfault in find by resource group
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(a)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;