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

刘金宝 liujinbao1 at xiaomi.com
Thu Mar 10 18:06:49 AEDT 2022


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)

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!******/#
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/linux-erofs/attachments/20220310/316a37ff/attachment.htm>


More information about the Linux-erofs mailing list