dlm: add missing kfrees

Previous thread: [h8300] move include/asm-h8300 to arch/h8300/include/asm by Linux Kernel Mailing List on Wednesday, August 13, 2008 - 3:59 pm. (1 message)

Next thread: [XFS] Use the generic bitops rather than implementing them ourselves. by Linux Kernel Mailing List on Wednesday, August 13, 2008 - 3:59 pm. (1 message)
From: Linux Kernel Mailing List
Date: Wednesday, August 13, 2008 - 3:59 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=cb980d...
Commit:     cb980d9a3ec3d39e30e0a4c473df528c09e0dcf3
Parent:     30a2f3c60a84092c8084dfe788b710f8d0768cd4
Author:     David Teigland <teigland@redhat.com>
AuthorDate: Tue Jul 29 15:21:19 2008 -0500
Committer:  David Teigland <teigland@redhat.com>
CommitDate: Wed Aug 13 12:47:36 2008 -0500

    dlm: add missing kfrees
    
    A couple of unlikely error conditions were missing a kfree on the error
    exit path.
    
    Reported-by: Juha Leppanen <juha_motorsportcom@luukku.com>
    Signed-off-by: David Teigland <teigland@redhat.com>
---
 fs/dlm/user.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index 929e48a..34f14a1 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -527,8 +527,10 @@ static ssize_t device_write(struct file *file, const char __user *buf,
 		k32buf = (struct dlm_write_request32 *)kbuf;
 		kbuf = kmalloc(count + 1 + (sizeof(struct dlm_write_request) -
 			       sizeof(struct dlm_write_request32)), GFP_KERNEL);
-		if (!kbuf)
+		if (!kbuf) {
+			kfree(k32buf);
 			return -ENOMEM;
+		}
 
 		if (proc)
 			set_bit(DLM_PROC_FLAGS_COMPAT, &proc->flags);
@@ -539,8 +541,10 @@ static ssize_t device_write(struct file *file, const char __user *buf,
 
 	/* do we really need this? can a write happen after a close? */
 	if ((kbuf->cmd == DLM_USER_LOCK || kbuf->cmd == DLM_USER_UNLOCK) &&
-	    (proc && test_bit(DLM_PROC_FLAGS_CLOSING, &proc->flags)))
-		return -EINVAL;
+	    (proc && test_bit(DLM_PROC_FLAGS_CLOSING, &proc->flags))) {
+		error = -EINVAL;
+		goto out_free;
+	}
 
 	sigfillset(&allsigs);
 	sigprocmask(SIG_BLOCK, &allsigs, &tmpsig);
--

Previous thread: [h8300] move include/asm-h8300 to arch/h8300/include/asm by Linux Kernel Mailing List on Wednesday, August 13, 2008 - 3:59 pm. (1 message)

Next thread: [XFS] Use the generic bitops rather than implementing them ourselves. by Linux Kernel Mailing List on Wednesday, August 13, 2008 - 3:59 pm. (1 message)