[PATCH] erofs-utils: lib: fix memory leak in xattr handling

Gao Xiang hsiangkao at linux.alibaba.com
Sat Jul 12 12:28:08 AEST 2025



On 2025/7/12 07:35, Sandeep Dhavale wrote:
> In android the LeakSanitizer reported memory leaks originating
> from functions like erofs_get_selabel_xattr.
> 
> The root cause is that the 'kvbuf' buffer, which is allocated to
> store xattr data, was not being freed when its owning
> 'xattr_item' struct was deallocated. The functions put_xattritem()
> and erofs_cleanxattrs() were freeing the xattr_item struct but
> neglected to free the kvbuf pointer within it.
> 
> This patch fixes the leak by adding the necessary free() calls for
> kvbuf in both functions.
> 
> Signed-off-by: Sandeep Dhavale <dhavale at google.com>

Reviewed-by: Gao Xiang <hsiangkao at linux.alibaba.com>

Thanks,
Gao Xiang


More information about the Linux-erofs mailing list