[PATCH] erofs-utils: mkfs: fix potential memory leak
Gao Xiang
hsiangkao at linux.alibaba.com
Sun Nov 5 23:46:45 AEDT 2023
On 2023/11/4 14:50, Yifan Zhao wrote:
> Valgrind reports 2 potential memory leaks in mkfs:
>
> Command: mkfs.erofs -zlz4 test.img testdir/
>
> 4 bytes in 1 blocks are still reachable in loss record 1 of 2
> at 0x4841848: malloc (vg_replace_malloc.c:431)
> by 0x49633DE: strdup (strdup.c:42)
> by 0x10C483: mkfs_parse_compress_algs (main.c:287)
> by 0x10C483: mkfs_parse_options_cfg (main.c:316)
> by 0x10C483: main (main.c:936)
>
> 34 bytes in 1 blocks are still reachable in loss record 2 of 2
> at 0x4841848: malloc (vg_replace_malloc.c:431)
> by 0x49633DE: strdup (strdup.c:42)
> by 0x48FFE2B: realpath_stk (canonicalize.c:409)
> by 0x48FFE2B: realpath@@GLIBC_2.3 (canonicalize.c:431)
> by 0x10B7EB: mkfs_parse_options_cfg (main.c:587)
> by 0x10B7EB: main (main.c:936)
>
> Fix it by freeing the memory allocated by strdup() and realpath().
>
> Signed-off-by: Yifan Zhao <zhaoyifan at sjtu.edu.cn>
Reviewed-by: Gao Xiang <hsiangkao at linux.alibaba.com>
BTW, would you mind adding a configuration to enable Valgrind?
Thanks,
Gao Xiang
More information about the Linux-erofs
mailing list