[Ocfs2-tools-devel] [PATCH] fix wrap assignment for extended slot map in ocfs2_store_slot_map()

Coly Li coly.li at suse.de
Mon Jun 15 01:06:00 PDT 2009


in ocfs2_store_slot_map(), no matter extended slot map is used, only wrap.mw_map
is initialized, which will introduce a wild memory accessing when extended slot
map is used.

When the extended slot map is first time initialized, all slots are zero bits,
therefore this bug will not hurt us most of the cases (if the wild memory
accessed are zero bits). But it's a real bug and this patch fixes it.

Signed-off-by: Coly Li <coly.li at suse.de>
---
 libocfs2/slot_map.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/libocfs2/slot_map.c b/libocfs2/slot_map.c
index c33f458..fac1991 100644
--- a/libocfs2/slot_map.c
+++ b/libocfs2/slot_map.c
@@ -334,7 +334,12 @@ errcode_t ocfs2_store_slot_map(ocfs2_filesys *fs,
 	ret = ocfs2_malloc0(bytes, &slot_map_buf);
 	if (ret)
 		return ret;
-	wrap.mw_map = (struct ocfs2_slot_map *)slot_map_buf;
+
+	if (extended)
+		wrap.mw_map_extended =
+			(struct ocfs2_slot_map_extened *)slot_map_buf;
+	else
+		wrap.mw_map = (struct ocfs2_slot_map *)slot_map_buf;

 	ocfs2_slot_data_to_map(fs, md, &wrap);
 	ret = __ocfs2_write_slot_map(fs, md->md_num_slots, &wrap);

-- 
Coly Li
SuSE Labs



More information about the Ocfs2-tools-devel mailing list