Skip to contentSkip to conversation

afs/super.c: Fix memory leak in afs_init_fs_context

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Jun 20, 2018 – Jun 22, 2018 Afs filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 afs/super.c: Fix memory leak in afs_init_fs_context

Release resources allocated for *ctx* before return.

Addresses-Coverity-ID: 1470101 ("Resource leak")

Fixes 1ec2b51af007 ("afs: Add fs_context support")
---
 fs/afs/super.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/afs/super.c +3 -1
index 656f810..037f20f 100644
@@ -596,8 +596,10 @@ static int afs_init_fs_context(struct fs_context *fc, struct dentry *reference)
 		break;
 
 	case FS_CONTEXT_FOR_SUBMOUNT:
-		if (!reference)
+		if (!reference) {
+			kfree(ctx);
 			return -EINVAL;
+		}
 
 		src_as = AFS_FS_S(reference->d_sb);
 		ASSERT(src_as);
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 1 line · Gustavo A. R. Silva

Release resources allocated for *ctx* before return.

I've folded that into the original patch, thanks.

David