LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File gfs2_edit_fix_bitmap_editing_function.patch of Package cluster (Project home:sschapiro:openstack:upstream)

commit 04ed614339bb64003f3cc42af9994ff637313618
Author: Steven Whitehouse <swhiteho@redhat.com>
Date:   Wed Oct 27 10:47:34 2010 +0100

    gfs2_edit: Fix bitmap editing function
    
    The bitmap editing function wasn't reading in the rgrp, so that it
    would fail with a NULL pointer dereference.
    
    rhbz#674843

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index c82ddae..abeed18 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -2557,28 +2557,28 @@ static void find_change_block_alloc(int *newval)
 	if (ablock == sbd.sb_addr)
 		printf("3 (the superblock is not in the bitmap)\n");
 	else {
-		if (newval) {
-			if (gfs2_set_bitmap(&sbd, ablock, *newval))
-				printf("-1 (block invalid or part of an rgrp).\n");
-			else
-				printf("%d\n", *newval);
-		} else {
-			rgd = gfs2_blk2rgrpd(&sbd, ablock);
-			if (rgd) {
-				gfs2_rgrp_read(&sbd, rgd);
+		rgd = gfs2_blk2rgrpd(&sbd, ablock);
+		if (rgd) {
+			gfs2_rgrp_read(&sbd, rgd);
+			if (newval) {
+				if (gfs2_set_bitmap(&sbd, ablock, *newval))
+					printf("-1 (block invalid or part of an rgrp).\n");
+				else
+					printf("%d\n", *newval);
+			} else {
 				type = gfs2_get_bitmap(&sbd, ablock, rgd);
-				gfs2_rgrp_relse(rgd);
 				if (type < 0) {
 					printf("-1 (block invalid or part of "
 					       "an rgrp).\n");
 					exit(-1);
 				}
 				printf("%d (%s)\n", type, allocdesc[gfs1][type]);
-			} else {
-				gfs2_rgrp_free(&sbd.rglist);
-				printf("-1 (block invalid or part of an rgrp).\n");
-				exit(-1);
 			}
+			gfs2_rgrp_relse(rgd);
+		} else {
+			gfs2_rgrp_free(&sbd.rglist);
+			printf("-1 (block invalid or part of an rgrp).\n");
+			exit(-1);
 		}
 	}
 	gfs2_rgrp_free(&sbd.rglist);