* [PATCH 0/2] Fix two mem leak bugs
@ 2020-03-03 9:40 Zhihao Cheng
2020-03-03 9:40 ` [PATCH 1/2] ubifs: ubifs_jnl_write_inode: Fix a memory leak bug Zhihao Cheng
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Zhihao Cheng @ 2020-03-03 9:40 UTC (permalink / raw)
To: richard, s.hauer, yi.zhang; +Cc: linux-mtd, linux-kernel
Zhihao Cheng (2):
ubifs: ubifs_jnl_write_inode: Fix a memory leak bug
ubifs: ubifs_add_orphan: Fix a memory leak bug
fs/ubifs/journal.c | 1 +
fs/ubifs/orphan.c | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
--
2.7.4
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] ubifs: ubifs_jnl_write_inode: Fix a memory leak bug
2020-03-03 9:40 [PATCH 0/2] Fix two mem leak bugs Zhihao Cheng
@ 2020-03-03 9:40 ` Zhihao Cheng
2020-03-03 9:40 ` [PATCH 2/2] ubifs: ubifs_add_orphan: " Zhihao Cheng
2020-03-08 22:22 ` [PATCH 0/2] Fix two mem leak bugs Richard Weinberger
2 siblings, 0 replies; 4+ messages in thread
From: Zhihao Cheng @ 2020-03-03 9:40 UTC (permalink / raw)
To: richard, s.hauer, yi.zhang; +Cc: linux-mtd, linux-kernel
When inodes with extended attributes are evicted, xent is not freed in one
exit branch.
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Fixes: 9ca2d732644484488db3112 ("ubifs: Limit number of xattrs per inode")
---
fs/ubifs/journal.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index 3bf8b1fda9d7..e5ec1afe1c66 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -905,6 +905,7 @@ int ubifs_jnl_write_inode(struct ubifs_info *c, const struct inode *inode)
ubifs_err(c, "dead directory entry '%s', error %d",
xent->name, err);
ubifs_ro_mode(c, err);
+ kfree(xent);
goto out_release;
}
ubifs_assert(c, ubifs_inode(xino)->xattr);
--
2.7.4
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ubifs: ubifs_add_orphan: Fix a memory leak bug
2020-03-03 9:40 [PATCH 0/2] Fix two mem leak bugs Zhihao Cheng
2020-03-03 9:40 ` [PATCH 1/2] ubifs: ubifs_jnl_write_inode: Fix a memory leak bug Zhihao Cheng
@ 2020-03-03 9:40 ` Zhihao Cheng
2020-03-08 22:22 ` [PATCH 0/2] Fix two mem leak bugs Richard Weinberger
2 siblings, 0 replies; 4+ messages in thread
From: Zhihao Cheng @ 2020-03-03 9:40 UTC (permalink / raw)
To: richard, s.hauer, yi.zhang; +Cc: linux-mtd, linux-kernel
Memory leak occurs when files with extended attributes are added to
orphan list.
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Fixes: 988bec41318f3fa897e2f8("ubifs: orphan: Handle xattrs like files")
---
fs/ubifs/orphan.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/ubifs/orphan.c b/fs/ubifs/orphan.c
index edf43ddd7dce..c769bf67e526 100644
--- a/fs/ubifs/orphan.c
+++ b/fs/ubifs/orphan.c
@@ -157,7 +157,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum)
int err = 0;
ino_t xattr_inum;
union ubifs_key key;
- struct ubifs_dent_node *xent;
+ struct ubifs_dent_node *xent, *pxent = NULL;
struct fscrypt_name nm = {0};
struct ubifs_orphan *xattr_orphan;
struct ubifs_orphan *orphan;
@@ -181,11 +181,16 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum)
xattr_inum = le64_to_cpu(xent->inum);
xattr_orphan = orphan_add(c, xattr_inum, orphan);
- if (IS_ERR(xattr_orphan))
+ if (IS_ERR(xattr_orphan)) {
+ kfree(xent);
return PTR_ERR(xattr_orphan);
+ }
+ kfree(pxent);
+ pxent = xent;
key_read(c, &xent->key, &key);
}
+ kfree(pxent);
return 0;
}
--
2.7.4
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] Fix two mem leak bugs
2020-03-03 9:40 [PATCH 0/2] Fix two mem leak bugs Zhihao Cheng
2020-03-03 9:40 ` [PATCH 1/2] ubifs: ubifs_jnl_write_inode: Fix a memory leak bug Zhihao Cheng
2020-03-03 9:40 ` [PATCH 2/2] ubifs: ubifs_add_orphan: " Zhihao Cheng
@ 2020-03-08 22:22 ` Richard Weinberger
2 siblings, 0 replies; 4+ messages in thread
From: Richard Weinberger @ 2020-03-08 22:22 UTC (permalink / raw)
To: Zhihao Cheng
Cc: Richard Weinberger, Sascha Hauer, linux-mtd, LKML, zhangyi (F)
On Tue, Mar 3, 2020 at 10:33 AM Zhihao Cheng <chengzhihao1@huawei.com> wrote:
>
> Zhihao Cheng (2):
> ubifs: ubifs_jnl_write_inode: Fix a memory leak bug
> ubifs: ubifs_add_orphan: Fix a memory leak bug
>
> fs/ubifs/journal.c | 1 +
> fs/ubifs/orphan.c | 9 +++++++--
> 2 files changed, 8 insertions(+), 2 deletions(-)
Thanks for fixing, applied!
--
Thanks,
//richard
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-08 22:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03 9:40 [PATCH 0/2] Fix two mem leak bugs Zhihao Cheng
2020-03-03 9:40 ` [PATCH 1/2] ubifs: ubifs_jnl_write_inode: Fix a memory leak bug Zhihao Cheng
2020-03-03 9:40 ` [PATCH 2/2] ubifs: ubifs_add_orphan: " Zhihao Cheng
2020-03-08 22:22 ` [PATCH 0/2] Fix two mem leak bugs Richard Weinberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).