Skip to contentSkip to conversation

9p: Fix memory leak in v9fs_mount

PATCH RESEND In review Zheng Bin 2 participants 4 messages Jun 15, 2020 – Jul 10, 2020

Subsystems (2)
lore
Share & tools
lore

Zheng Bin

author
#0 lore raw

PATCH RESEND 1/1 9p: Fix memory leak in v9fs_mount

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.

---
 fs/9p/v9fs.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fs/9p/v9fs.c +2 -3
index 15a99f9c7253..39def020a074 100644
@@ -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

#1 lore raw

Zheng Bin wrote on Mon, Jun 15, 2020:

Quoted 11 lines

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)
Quoted 3 lines

Thus memleak happens.

Thanks, will run tests & queue next weekend

Signature · 1 line
Dominique
#2 lore raw

Is this OK? I don't see it on linux-next

Quoted 17 lines · Dominique Martinet

Zheng Bin wrote on Mon, Jun 15, 2020:

Quoted 11 lines

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)
Quoted 3 lines

Thus memleak happens.

Thanks, will run tests & queue next weekend

#3 lore raw

Zhengbin (OSKernel) wrote on Thu, Jul 09, 2020:

Quoted 1 line

Is this OK? I don't see it on linux-next

Yes, I just (still) haven't tested them, sorry. It's in git://github.com/martinetd/linux branch 9p-test

Signature · 1 line
Dominique