Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH RESEND] 9p: Fix memory leak in v9fs_mount
@ 2020-06-15  1:21 Zheng Bin
  2020-06-15 10:20 ` Dominique Martinet
  0 siblings, 1 reply; 4+ messages in thread
From: Zheng Bin @ 2020-06-15  1:21 UTC (permalink / raw)
  To: ericvh, lucho, asmadeus, v9fs-developer, linux-fsdevel, linux-kernel
  Cc: yi.zhang, zhengbin13

v9fs_mount
  v9fs_session_init
    v9fs_cache_session_get_cookie
      v9fs_random_cachetag                     -->alloc cachetag
      v9ses->fscache = fscache_acquire_cookie  -->maybe NULL
  sb = sget                                    -->fail, goto clunk
clunk_fid:
  v9fs_session_close
    if (v9ses->fscache)                        -->NULL
      kfree(v9ses->cachetag)

Thus memleak happens.

Signed-off-by: Zheng Bin <zhengbin13@huawei.com>
---
 fs/9p/v9fs.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 15a99f9c7253..39def020a074 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -500,10 +500,9 @@ void v9fs_session_close(struct v9fs_session_info *v9ses)
 	}

 #ifdef CONFIG_9P_FSCACHE
-	if (v9ses->fscache) {
+	if (v9ses->fscache)
 		v9fs_cache_session_put_cookie(v9ses);
-		kfree(v9ses->cachetag);
-	}
+	kfree(v9ses->cachetag);
 #endif
 	kfree(v9ses->uname);
 	kfree(v9ses->aname);
--
2.26.0.106.g9fadedd


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

end of thread, other threads:[~2020-07-10 11:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15  1:21 [PATCH RESEND] 9p: Fix memory leak in v9fs_mount Zheng Bin
2020-06-15 10:20 ` Dominique Martinet
2020-07-09  2:04   ` Zhengbin (OSKernel)
2020-07-10 11:05     ` Dominique Martinet

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).