* [PATCH -next] afs: Fix the memory leak in afs_mkdir
@ 2020-06-23 11:15 Chen Tao
2020-06-24 12:16 ` David Howells
0 siblings, 1 reply; 2+ messages in thread
From: Chen Tao @ 2020-06-23 11:15 UTC (permalink / raw)
To: dhowells; +Cc: linux-afs, linux-kernel, chentao107
Fix the memory leak in afs_mkdir not freeing scb
in error path.
Fixes: a58823ac45896 ("afs: Fix application of status and callback to be under same lock")
Signed-off-by: Chen Tao <chentao107@huawei.com>
---
fs/afs/dir.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index d1e1caa23c8b..ab5472ad1da8 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -1599,17 +1599,17 @@ static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
if (dentry->d_name.len >= AFSNAMEMAX)
goto error;
- key = afs_request_key(dvnode->volume->cell);
- if (IS_ERR(key)) {
- ret = PTR_ERR(key);
- goto error;
- }
-
ret = -ENOMEM;
scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL);
if (!scb)
goto error_scb;
+ key = afs_request_key(dvnode->volume->cell);
+ if (IS_ERR(key)) {
+ ret = PTR_ERR(key);
+ goto error_scb;
+ }
+
ret = -ERESTARTSYS;
if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
data_version = dvnode->status.data_version + 1;
@@ -1645,10 +1645,10 @@ static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
_leave(" = 0");
return 0;
-error_scb:
- kfree(scb);
error_key:
key_put(key);
+error_scb:
+ kfree(scb);
error:
d_drop(dentry);
_leave(" = %d", ret);
--
2.22.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH -next] afs: Fix the memory leak in afs_mkdir
2020-06-23 11:15 [PATCH -next] afs: Fix the memory leak in afs_mkdir Chen Tao
@ 2020-06-24 12:16 ` David Howells
0 siblings, 0 replies; 2+ messages in thread
From: David Howells @ 2020-06-24 12:16 UTC (permalink / raw)
To: Chen Tao; +Cc: dhowells, linux-afs, linux-kernel
Hi Chen,
> Fix the memory leak in afs_mkdir not freeing scb
> in error path.
This code has changed substantially in linus/master.
David
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-24 12:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23 11:15 [PATCH -next] afs: Fix the memory leak in afs_mkdir Chen Tao
2020-06-24 12:16 ` David Howells
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®