Skip to contentSkip to conversation

NFSv4: Fix memory leak in nfs4_set_security_label

PATCH In review Dmitry Mastykin 2 participants 2 messages May 22, 2024

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

PATCH 1/1 NFSv4: Fix memory leak in nfs4_set_security_label

We leak nfs_fattr and nfs4_label every time we set a security xattr.

---
 fs/nfs/nfs4proc.c | 1 +
 1 file changed, 1 insertion(+)
fs/nfs/nfs4proc.c +1 -0
index ea390db94b62..d400093a2fff 100644
@@ -6268,6 +6268,7 @@ nfs4_set_security_label(struct inode *inode, const void *buf, size_t buflen)
 	if (status == 0)
 		nfs_setsecurity(inode, fattr);
 
+	nfs_free_fattr(fattr);
 	return status;
 }
 #endif	/* CONFIG_NFS_V4_SECURITY_LABEL */
Signature · 1 line
2.30.2
#1 lore raw
Quoted 22 lines · Dmitry Mastykin

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

We leak nfs_fattr and nfs4_label every time we set a security xattr.

---
 fs/nfs/nfs4proc.c | 1 +

 1 file changed, 1 insertion(+)
fs/nfs/nfs4proc.c +1 -0
index ea390db94b62..d400093a2fff 100644
@@ -6268,6 +6268,7 @@ nfs4_set_security_label(struct inode *inode,
 const void *buf, size_t buflen)
         if (status == 0)
                 nfs_setsecurity(inode, fattr);
 
+       nfs_free_fattr(fattr);
         return status;
  }
Quoted 4 lines

 #endif /* CONFIG_NFS_V4_SECURITY_LABEL */
--
2.30.2

Thanks! For future reference, please note the section on indenting in the file Documentation/process/coding-style.rst as your patch above was whitespace-broken and so didn't apply cleanly.
Since this was just a 1-liner, I've fixed it up for now, so no need to resubmit.

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]