gfs2-utils: master - gfs2_edit: Fix null pointer derefs in display_block_type()

Andrew Price andyp at fedoraproject.org
Fri Jan 6 15:27:44 UTC 2012


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=8c322343d559a671a0ed84488a59b475a247ae69
Commit:        8c322343d559a671a0ed84488a59b475a247ae69
Parent:        1be8f8542ab8f7154104403e0a15886c7023c214
Author:        Andrew Price <anprice at redhat.com>
AuthorDate:    Fri Jan 6 15:11:48 2012 +0000
Committer:     Andrew Price <anprice at redhat.com>
CommitterDate: Fri Jan 6 15:11:48 2012 +0000

gfs2_edit: Fix null pointer derefs in display_block_type()

Spotted by coverity: Dereferencing null variable "rgd".

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

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 02a4091..69d499e 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -713,7 +713,7 @@ int display_block_type(int from_restore)
 		if ((be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RG)) {
 			int ptroffset = edit_row[dmode] * 16 + edit_col[dmode];
 
-			if (ptroffset >= struct_len || pgnum) {
+			if (rgd && (ptroffset >= struct_len || pgnum)) {
 				int blknum, b, btype;
 
 				blknum = pgnum * screen_chunk_size;
@@ -731,7 +731,7 @@ int display_block_type(int from_restore)
 		} else if ((be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RB)) {
 			int ptroffset = edit_row[dmode] * 16 + edit_col[dmode];
 
-			if (ptroffset >= struct_len || pgnum) {
+			if (rgd && (ptroffset >= struct_len || pgnum)) {
 				int blknum, b, btype, rb_number;
 
 				rb_number = block - rgd->ri.ri_addr;


More information about the cluster-commits mailing list