All of lore.kernel.org
 help / color / mirror / Atom feed
* [erofs-utils] Report two resource leak issues and submit patches
@ 2022-03-10  7:06 刘金宝 via Linux-erofs
  2022-03-10  7:22 ` Gao Xiang
  0 siblings, 1 reply; 2+ messages in thread
From: 刘金宝 via Linux-erofs @ 2022-03-10  7:06 UTC (permalink / raw)
  To: linux-erofs; +Cc: Jianhua1 Hao 郝建华

[-- Attachment #1: Type: text/plain, Size: 1741 bytes --]

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!******/#

[-- Attachment #2: Type: text/html, Size: 8083 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [erofs-utils] Report two resource leak issues and submit patches
  2022-03-10  7:06 [erofs-utils] Report two resource leak issues and submit patches 刘金宝 via Linux-erofs
@ 2022-03-10  7:22 ` Gao Xiang
  0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2022-03-10  7:22 UTC (permalink / raw)
  To: 刘金宝
  Cc: linux-erofs, Jianhua1 Hao 郝建华

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!******/#

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-10  7:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10  7:06 [erofs-utils] Report two resource leak issues and submit patches 刘金宝 via Linux-erofs
2022-03-10  7:22 ` Gao Xiang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.