* [PATCH] fuse: Fix a potential memory leak for kstrdup()
@ 2022-07-15 7:53 williamsukatube
2022-07-15 14:06 ` Miklos Szeredi
0 siblings, 1 reply; 2+ messages in thread
From: williamsukatube @ 2022-07-15 7:53 UTC (permalink / raw
To: miklos, linux-fsdevel, linux-kernel; +Cc: William Dean, Hacash Robot
From: William Dean <williamsukatube@gmail.com>
kfree() is missing on an error path to free the memory allocated by
kstrdup():
sb->s_subtype = kstrdup(parent_sb->s_subtype, GFP_KERNEL);
So it is better to free it via kfree(sb->s_subtype).
Fixes: 1866d779d5d2a ("fuse: Allow fuse_fill_super_common() for submounts")
Reported-by: Hacash Robot <hacashRobot@santino.com>
Signed-off-by: William Dean <williamsukatube@gmail.com>
---
fs/fuse/inode.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 8c0665c5dff8..2d10afad07f8 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1449,8 +1449,10 @@ static int fuse_fill_super_submount(struct super_block *sb,
get_fuse_inode(root)->nlookup--;
sb->s_d_op = &fuse_dentry_operations;
sb->s_root = d_make_root(root);
- if (!sb->s_root)
+ if (!sb->s_root) {
+ kfree(sb->s_subtype);
return -ENOMEM;
+ }
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fuse: Fix a potential memory leak for kstrdup()
2022-07-15 7:53 [PATCH] fuse: Fix a potential memory leak for kstrdup() williamsukatube
@ 2022-07-15 14:06 ` Miklos Szeredi
0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2022-07-15 14:06 UTC (permalink / raw
To: williamsukatube; +Cc: linux-fsdevel, linux-kernel, William Dean, Hacash Robot
On Fri, 15 Jul 2022 at 09:54, <williamsukatube@163.com> wrote:
>
> From: William Dean <williamsukatube@gmail.com>
>
> kfree() is missing on an error path to free the memory allocated by
> kstrdup():
>
> sb->s_subtype = kstrdup(parent_sb->s_subtype, GFP_KERNEL);
>
> So it is better to free it via kfree(sb->s_subtype).
Not needed. s_subtype will be freed in __put_super().
Thanks,
Miklos
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-15 14:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-15 7:53 [PATCH] fuse: Fix a potential memory leak for kstrdup() williamsukatube
2022-07-15 14:06 ` Miklos Szeredi
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 read-only IMAP folder(s) and NNTP newsgroup(s).