[Ocfs2-tools-devel] [PATCH]debugfs.ocfs2: fix segmentation fault in do_slotmap()

Coly Li coyli at suse.de
Tue May 20 19:58:52 PDT 2008


In do_slotmap(), avoid accessing super block info before calling check_device_open(), otherwise, a
SIGSEG will come.

Signed-off-by: Coly Li <coyli at suse.de>
---

diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
index de9bc7e..bfcda4e 100644
--- a/debugfs.ocfs2/commands.c
+++ b/debugfs.ocfs2/commands.c
@@ -1203,13 +1203,14 @@ static void do_slotmap (char **args)
 {
 	FILE *out;
 	errcode_t ret;
-	int num_slots = OCFS2_RAW_SB(gbls.fs->fs_super)->s_max_slots;
+	int num_slots;
 	struct ocfs2_slot_map_extended *se = NULL;
 	struct ocfs2_slot_map *sm = NULL;

 	if (check_device_open())
 		return ;

+	num_slots = OCFS2_RAW_SB(gbls.fs->fs_super)->s_max_slots;
 	if (ocfs2_uses_extended_slot_map(OCFS2_RAW_SB(gbls.fs->fs_super)))
 		ret = ocfs2_read_slot_map_extended(gbls.fs, num_slots, &se);
 	else


-- 
Coly Li
SuSE PRC Labs



More information about the Ocfs2-tools-devel mailing list