Skip to contentSkip to conversation

NFSv4: fix memory leak if nfs4_begin_drain_session fails

PATCH In review Navid Emamdoost 2 participants 3 messages Sep 20, 2019 – Nov 12, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFSv4: fix memory leak if nfs4_begin_drain_session fails

In nfs4_try_migration, if nfs4_begin_drain_session fails the allocated memory should be released.

---
 fs/nfs/nfs4state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4state.c +1 -1
index cad4e064b328..124649f12067 100644
@@ -2096,7 +2096,7 @@ static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred
 
 	status = nfs4_begin_drain_session(clp);
 	if (status != 0)
-		return status;
+		goto out;
 
 	status = nfs4_replace_transport(server, locations);
 	if (status != 0) {
Signature · 1 line
2.17.1
#1 lore raw

Would you please review this patch?

Quoted 25 lines · Navid Emamdoost

In nfs4_try_migration, if nfs4_begin_drain_session fails the allocated memory should be released.

---
 fs/nfs/nfs4state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4state.c +1 -2
index cad4e064b328..124649f12067 100644
@@ -2096,7 +2096,7 @@ static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred
 
        status = nfs4_begin_drain_session(clp);
        if (status != 0)
-               return status;
+               goto out;
 
        status = nfs4_replace_transport(server, locations);
        if (status != 0) {
--

2.17.1

Signature · 1 line
Navid.
#2 lore raw

Hi Navid,

Quoted 1 line · Navid Emamdoost

Would you please review this patch?

This memory leak was fixed by:

commit 1e672e3644940d83bd94e7cb46bac6bb3627de02

Author: Wenwen Wang <[email protected]>
Date:   Tue Aug 20 22:21:21 2019 -0500

NFSv4: Fix a memory leak bug

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.

And was included as part of the initial NFS merge for the v5.4-rc cycle.

Thanks,
Anna

Quoted 31 lines
Quoted 22 lines · Navid Emamdoost

In nfs4_try_migration, if nfs4_begin_drain_session fails the allocated memory should be released.

---
 fs/nfs/nfs4state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4state.c +1 -1
index cad4e064b328..124649f12067 100644
@@ -2096,7 +2096,7 @@ static int nfs4_try_migration(struct nfs_server
 *server, const struct cred *cred
 
        status = nfs4_begin_drain_session(clp);
        if (status != 0)
-               return status;
+               goto out;
 
        status = nfs4_replace_transport(server, locations);
        if (status != 0) {
Quoted 3 lines

--
2.17.1

--
Navid.