Skip to content

Commit

Permalink
9p: Fix memory leak in v9fs_mount
Browse files Browse the repository at this point in the history
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.

Link: http://lkml.kernel.org/r/[email protected]
Fixes: 60e78d2 ("9p: Add fscache support to 9p")
Cc: <[email protected]> # v2.6.32+
Signed-off-by: Zheng Bin <[email protected]>
Signed-off-by: Dominique Martinet <[email protected]>
  • Loading branch information
zhengbin13 authored and martinetd committed Jul 19, 2020
1 parent 6624664 commit cb0aae0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions fs/9p/v9fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cb0aae0

Please sign in to comment.