[erofs-utils] Report two resource leak issues and submit patches

Gao Xiang hsiangkao at linux.alibaba.com
Thu Mar 10 18:22:18 AEDT 2022


Hi,

On Thu, Mar 10, 2022 at 07:06:49AM +0000, 刘金宝 via Linux-erofs wrote:
> Hello,
> There are two resource leak problems and patches here.
> Problem 1: Resource leakage
> File: erofs-utils/lib/xattr.c
> Function: erofs_get_selabel_xattr
> Statement: ret = asprintf(&fspath, "/%s", erofs_fspath(srcpath));
> if (ret <= 0)
> return ERR_PTR(-ENOMEM);
> Analysis: When the asprintf function fails, it returns -1, so the judgment condition should be ret<0. Return when ret=0, the storage pointed to by fspath will be leaked
> Patch: if (ret < 0)
> 
> Problem 2: Resource leakage
> File: erofs-utils/lib/inode.c
> Function: erofs_droid_inode_fsconfig
> Statement: if (asprintf(&decorated, "%s/%s", cfg.mount_point, erofs_fspath(path)) <= 0)
> return -ENOMEM;
> Analysis: When the asprintf function fails, it returns -1, so the judgment condition should be ret<0. Return when asprintf(&decorated, "%s/%s", cfg.mount_point, erofs_fspath(path)) = 0, the storage pointed to by decorated will be leaked
> Patch: if (asprintf(&decorated, "%s/%s", cfg.mount_point, erofs_fspath(path)) < 0)
> 

Thanks for the report!

Since you already have solutions, would you mind submitting
2 independent patches for these?

Thanks,
Gao Xiang

> Thank you!
> Jinbao Liu
> 
> 
> 
> #/******本邮件及其附件含有小米公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#


More information about the Linux-erofs mailing list