Skip to contentSkip to conversation

nfs: fix unlikely memory leak

PATCH In review Dan Carpenter 2 participants 2 messages Mar 6, 2010

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

PATCH 1/1 nfs: fix unlikely memory leak

I'll admit that it's unlikely for the first allocation to fail and the second one to succeed. I won't be offended if you ignore this patch.

fs/nfs/nfs4proc.c +1 -0
index eda74c4..f9254fb 100644
@@ -5107,6 +5107,7 @@ static int nfs41_proc_async_sequence(struct nfs_client *clp,
 	res = kzalloc(sizeof(*res), GFP_KERNEL);
 	if (!args || !res) {
 		kfree(args);
+		kfree(res);
 		nfs_put_client(clp);
 		return -ENOMEM;
 	}
#1 lore raw
Quoted 11 lines · Dan Carpenter

I'll admit that it's unlikely for the first allocation to fail and the second one to succeed. I won't be offended if you ignore this patch.

fs/nfs/nfs4proc.c +0 -0
index eda74c4..f9254fb 100644

fs/nfs/nfs4proc.c static int nfs41_proc_async_sequence(struct nfs_client *clp, · line 5113

Quoted 7 lines
fs/nfs/nfs4proc.c +1 -0
@@ -5107,6 +5107,7 @@ static int nfs41_proc_async_sequence(struct nfs_client *clp,
 	res = kzalloc(sizeof(*res), GFP_KERNEL);
 	if (!args || !res) {
 		kfree(args);
+		kfree(res);
 		nfs_put_client(clp);
 		return -ENOMEM;
 	}

It's a good point. I will apply...

Cheers
Trond