* [PATCH] cifs: Fix a small memory leak in directory creation code.
@ 2007-09-16 21:15 Jesper Juhl
0 siblings, 0 replies; only message in thread
From: Jesper Juhl @ 2007-09-16 21:15 UTC (permalink / raw)
To: Steve French
Cc: Steve French, linux-cifs-client, samba-technical,
Linux Kernel Mailing List, Jesper Juhl
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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-09-16 21:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-16 21:15 [PATCH] cifs: Fix a small memory leak in directory creation code Jesper Juhl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox