diff options
author | Steve French <sfrench@us.ibm.com> | 2007-09-16 19:12:47 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2007-09-16 19:12:47 -0400 |
commit | 5a07cdf86c1485b570789fb660c8ada7c2635b23 (patch) | |
tree | dff7e4481c0866b7feae969d14c03ee61eddc494 /fs/cifs/inode.c | |
parent | a23d30698190f05491a6096f027311f94d4d26d5 (diff) |
[CIFS] fix small memory leak in an error path in new posix mkdir
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>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/inode.c')
-rw-r--r-- | fs/cifs/inode.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index e800c0ef54f6..9dffa93d6bdd 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -930,8 +930,10 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
930 | d_drop(direntry); | 930 | d_drop(direntry); |
931 | } else { | 931 | } else { |
932 | int obj_type; | 932 | int obj_type; |
933 | if (pInfo->Type == -1) /* no return info - go query */ | 933 | if (pInfo->Type == -1) /* no return info - go query */ { |
934 | kfree(pInfo); | ||
934 | goto mkdir_get_info; | 935 | goto mkdir_get_info; |
936 | } | ||
935 | /*BB check (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID ) to see if need | 937 | /*BB check (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID ) to see if need |
936 | to set uid/gid */ | 938 | to set uid/gid */ |
937 | inc_nlink(inode); | 939 | inc_nlink(inode); |
@@ -941,8 +943,10 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode) | |||
941 | direntry->d_op = &cifs_dentry_ops; | 943 | direntry->d_op = &cifs_dentry_ops; |
942 | 944 | ||
943 | newinode = new_inode(inode->i_sb); | 945 | newinode = new_inode(inode->i_sb); |
944 | if (newinode == NULL) | 946 | if (newinode == NULL) { |
947 | kfree(pInfo); | ||
945 | goto mkdir_get_info; | 948 | goto mkdir_get_info; |
949 | } | ||
946 | /* Is an i_ino of zero legal? */ | 950 | /* Is an i_ino of zero legal? */ |
947 | /* Are there sanity checks we can use to ensure that | 951 | /* Are there sanity checks we can use to ensure that |
948 | the server is really filling in that field? */ | 952 | the server is really filling in that field? */ |