[Ocfs2-tools-devel] [PATCH 5/6] tunefs.ocfs2: Check the validity of variables before use
piaojun
piaojun at huawei.com
Wed Mar 25 23:58:01 PDT 2015
In clean_indexed_dirs(), expand_inline_data() and install_trailers(), we
need check if prog is null before use.
Signed-off-by: Jun Piao <piaojun at huawei.com>
Reviewed-by: Alex Chen <alex.chen at huawei.com>
---
tunefs.ocfs2/feature_indexed_dirs.c | 3 ++-
tunefs.ocfs2/feature_inline_data.c | 2 +-
tunefs.ocfs2/feature_metaecc.c | 2 ++
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/tunefs.ocfs2/feature_indexed_dirs.c b/tunefs.ocfs2/feature_indexed_dirs.c
index ead9a48..7f38292 100644
--- a/tunefs.ocfs2/feature_indexed_dirs.c
+++ b/tunefs.ocfs2/feature_indexed_dirs.c
@@ -245,7 +245,8 @@ static errcode_t clean_indexed_dirs(ocfs2_filesys *fs,
}
bail:
- tools_progress_stop(prog);
+ if (prog)
+ tools_progress_stop(prog);
verbosef(VL_APP,
"\"%"PRIu64"\" from \"%"PRIu64"\" indexed %s truncated.",
dirs_truncated, ctxt->dx_dirs_nr,
diff --git a/tunefs.ocfs2/feature_inline_data.c b/tunefs.ocfs2/feature_inline_data.c
index 9e1d07f..8367f59 100644
--- a/tunefs.ocfs2/feature_inline_data.c
+++ b/tunefs.ocfs2/feature_inline_data.c
@@ -182,7 +182,7 @@ static errcode_t expand_inline_data(ocfs2_filesys *fs,
prog = tools_progress_start("Expanding inline files", "expanding",
ctxt->more_clusters);
- if (!ctxt->prog)
+ if (!prog || !ctxt->prog)
return TUNEFS_ET_NO_MEMORY;
ret = ocfs2_load_fs_quota_info(fs);
diff --git a/tunefs.ocfs2/feature_metaecc.c b/tunefs.ocfs2/feature_metaecc.c
index c9c2709..f0efd2c 100644
--- a/tunefs.ocfs2/feature_metaecc.c
+++ b/tunefs.ocfs2/feature_metaecc.c
@@ -666,6 +666,8 @@ static errcode_t install_trailers(ocfs2_filesys *fs,
prog = tools_progress_start("Installing dir trailers",
"trailers", ctxt->ae_dircount);
+ if (!prog)
+ return TUNEFS_ET_NO_MEMORY;
list_for_each_safe(pos, n, &ctxt->ae_dirs) {
tc = list_entry(pos, struct tunefs_trailer_context, d_list);
verbosef(VL_DEBUG,
-- 1.8.4.3
More information about the Ocfs2-tools-devel
mailing list