From 8133ffd09f5928859750681dc1166656c2ccb59d Mon Sep 17 00:00:00 2001 From: Wenwen Wang Date: Tue, 29 Oct 2019 16:18:22 +0800 Subject: [PATCH] NFSv4: Fix a memory leak bug mainline inclusion from mainline-v5.4 commit 1e672e3644940d83bd94e7cb46bac6bb3627de02 category: bugfix bugzilla: 23341 CVE: NA ------------------------------------------------- In nfs4_try_migration(), if nfs4_begin_drain_session() fails, the previously allocated 'page' and 'locations' are not deallocated, leading to memory leaks. To fix this issue, go to the 'out' label to free 'page' and 'locations' before returning the error. Signed-off-by: Wenwen Wang Signed-off-by: Anna Schumaker v1->v2: add bugzilla id. Signed-off-by: Zhang Xiaoxu Reviewed-by: zhangyi (F) Signed-off-by: Yang Yingliang --- fs/nfs/nfs4state.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index c36ef75f2054..ef90424ab06f 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -2073,8 +2073,10 @@ static int nfs4_try_migration(struct nfs_server *server, struct rpc_cred *cred) } status = nfs4_begin_drain_session(clp); - if (status != 0) - return status; + if (status != 0) { + result = status; + goto out; + } status = nfs4_replace_transport(server, locations); if (status != 0) { -- GitLab