diff mbox series

[RESEND] 9p: Fix memory leak in v9fs_mount

Message ID 20200615012153.89538-1-zhengbin13@huawei.com (mailing list archive)
State New, archived
Headers show
Series [RESEND] 9p: Fix memory leak in v9fs_mount | expand

Commit Message

Zheng Bin June 15, 2020, 1:21 a.m. UTC
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(-)

--
2.26.0.106.g9fadedd

Comments

Dominique Martinet June 15, 2020, 10:20 a.m. UTC | #1
Zheng Bin wrote on Mon, Jun 15, 2020:
> 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>

Thanks, will run tests & queue next weekend
Zheng Bin July 9, 2020, 2:04 a.m. UTC | #2
Is this OK? I don't see it on linux-next

On 2020/6/15 18:20, Dominique Martinet wrote:
> Zheng Bin wrote on Mon, Jun 15, 2020:
>> 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>
> Thanks, will run tests & queue next weekend
>
Dominique Martinet July 10, 2020, 11:05 a.m. UTC | #3
Zhengbin (OSKernel) wrote on Thu, Jul 09, 2020:
> 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
diff mbox series

Patch

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