[Ocfs2-tools-devel] [PATCH] libocfs2: check sectsize after return from ocfs2_get_device_sectsize()
Coly Li
coly.li at suse.de
Fri Feb 27 02:02:10 PST 2009
In ocfs2_get_device_sectsize(), if BLKSSZGET is undefined, *sectsize is set to 0. This is
problematic in ocfs2_fill_heartbeat_desc() where
sectsize_bits = ffs(sectsize) - 1;
will gets sectsize_bits to be ~0. Though the execution flow is safe, the logic is not correct.
This patch check paramter sectsize after return from ocfs2_get_device_sectsize(), if sectsize is set
to 0, goto leave.
Signed-off-by: Coly Li <coly.li at suse.de>
---
libocfs2/heartbeat.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libocfs2/heartbeat.c b/libocfs2/heartbeat.c
index 193617a..8e8a850 100644
--- a/libocfs2/heartbeat.c
+++ b/libocfs2/heartbeat.c
@@ -54,7 +54,7 @@ errcode_t ocfs2_fill_heartbeat_desc(ocfs2_filesys *fs,
struct ocfs2_extent_rec *rec;
ret = ocfs2_get_device_sectsize(fs->fs_devname, §size);
- if (ret)
+ if (ret || !sectsize)
goto leave;
sectsize_bits = ffs(sectsize) - 1;
--
Coly Li
SuSE Labs
More information about the Ocfs2-tools-devel
mailing list