public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jesper Juhl <jesper.juhl@gmail.com>
To: Steve French <sfrench@samba.org>
Cc: Steve French <sfrench@us.ibm.com>,
	linux-cifs-client@lists.samba.org,
	samba-technical@lists.samba.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Jesper Juhl <jesper.juhl@gmail.com>
Subject: [PATCH] cifs: Fix a small memory leak in directory creation code.
Date: Sun, 16 Sep 2007 23:15:03 +0200	[thread overview]
Message-ID: <200709162315.03569.jesper.juhl@gmail.com> (raw)


There is a small memory leak in fs/cifs/inode.c::cifs_mkdir().
Storage for 'pInfo' is allocated with kzalloc(), but if the call  
to CIFSPOSIXCreate(...) happens to return 0 and pInfo->Type == -1, 
then we'll jump to the 'mkdir_get_info' label without freeing the 
storage allocated for 'pInfo'.
This patch adds a kfree() call to free the storage just before 
jumping to the label, thus getting rid of the leak.


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 inode.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- linux-2.6/fs/cifs/inode.c~	2007-09-16 23:01:52.000000000 +0200
+++ linux-2.6/fs/cifs/inode.c	2007-09-16 23:01:52.000000000 +0200
@@ -929,8 +929,10 @@ int cifs_mkdir(struct inode *inode, stru
 			d_drop(direntry);
 		} else {
 			int obj_type;
-			if (pInfo->Type == -1) /* no return info - go query */
+			if (pInfo->Type == -1) { /* no return info - go query */
+				kfree(pInfo);
 				goto mkdir_get_info;
+			}
 /*BB check (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID ) to see if need
 	to set uid/gid */
 			inc_nlink(inode);



                 reply	other threads:[~2007-09-16 21:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200709162315.03569.jesper.juhl@gmail.com \
    --to=jesper.juhl@gmail.com \
    --cc=linux-cifs-client@lists.samba.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    --cc=sfrench@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox