[Ocfs2-tools-devel] [PATCH] fsck.ocfs2: warn and return if ocfs2_malloc fails in walk_cwd
Joseph Qi
joseph.qi at huawei.com
Mon May 16 03:33:21 PDT 2016
On 2016/5/16 17:39, piaojun wrote:
> In walk_cwd, we should check return code in case of ocfs2_malloc fails.
> Otherwise, segment fault will happen.
>
> Fixes: 6b689d45289d ("fsck.ocfs2: dynamically allocate ocfs2_dir_entry
> for long filenames")
>
> Signed-off-by: Jun Piao <piaojun at huawei.com>
Reviewed-by: Joseph Qi <joseph.qi at huawei.com>
> ---
> fsck.ocfs2/pass1b.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fsck.ocfs2/pass1b.c b/fsck.ocfs2/pass1b.c
> index e3ee739..fc380ec 100644
> --- a/fsck.ocfs2/pass1b.c
> +++ b/fsck.ocfs2/pass1b.c
> @@ -969,6 +969,10 @@ static void walk_cwd(struct dir_scan_context *scan)
> - OCFS2_MAX_FILENAME_LEN;
>
> ret = ocfs2_malloc(len, &de);
> + if (ret) {
> + pass1c_warn(ret);
> + return;
> + }
>
> memcpy(de->name, scan->ds_cwd, scan->ds_cwdlen);
> de->name_len = scan->ds_cwdlen;
>
More information about the Ocfs2-tools-devel
mailing list