mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 09:31:14 +00:00
cifs: possible memory leak in xattr.
Memory is allocated irrespective of whether CIFS_ACL is configured or not. But free is happenning only if CIFS_ACL is set. This is a possible memory leak scenario. Fix is: Allocate and free memory only if CIFS_ACL is configured. Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com> Reviewed-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
parent
55062d0617
commit
b0f8ef202e
1 changed files with 3 additions and 3 deletions
|
@ -105,7 +105,6 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
|
||||||
struct cifs_tcon *pTcon;
|
struct cifs_tcon *pTcon;
|
||||||
struct super_block *sb;
|
struct super_block *sb;
|
||||||
char *full_path;
|
char *full_path;
|
||||||
struct cifs_ntsd *pacl;
|
|
||||||
|
|
||||||
if (direntry == NULL)
|
if (direntry == NULL)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
@ -164,23 +163,24 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
|
||||||
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
||||||
} else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL,
|
} else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL,
|
||||||
strlen(CIFS_XATTR_CIFS_ACL)) == 0) {
|
strlen(CIFS_XATTR_CIFS_ACL)) == 0) {
|
||||||
|
#ifdef CONFIG_CIFS_ACL
|
||||||
|
struct cifs_ntsd *pacl;
|
||||||
pacl = kmalloc(value_size, GFP_KERNEL);
|
pacl = kmalloc(value_size, GFP_KERNEL);
|
||||||
if (!pacl) {
|
if (!pacl) {
|
||||||
cFYI(1, "%s: Can't allocate memory for ACL",
|
cFYI(1, "%s: Can't allocate memory for ACL",
|
||||||
__func__);
|
__func__);
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
} else {
|
} else {
|
||||||
#ifdef CONFIG_CIFS_ACL
|
|
||||||
memcpy(pacl, ea_value, value_size);
|
memcpy(pacl, ea_value, value_size);
|
||||||
rc = set_cifs_acl(pacl, value_size,
|
rc = set_cifs_acl(pacl, value_size,
|
||||||
direntry->d_inode, full_path, CIFS_ACL_DACL);
|
direntry->d_inode, full_path, CIFS_ACL_DACL);
|
||||||
if (rc == 0) /* force revalidate of the inode */
|
if (rc == 0) /* force revalidate of the inode */
|
||||||
CIFS_I(direntry->d_inode)->time = 0;
|
CIFS_I(direntry->d_inode)->time = 0;
|
||||||
kfree(pacl);
|
kfree(pacl);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
cFYI(1, "Set CIFS ACL not supported yet");
|
cFYI(1, "Set CIFS ACL not supported yet");
|
||||||
#endif /* CONFIG_CIFS_ACL */
|
#endif /* CONFIG_CIFS_ACL */
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
int temp;
|
int temp;
|
||||||
temp = strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
|
temp = strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue