mirror of https://gitee.com/openkylin/linux.git
configfs: handle kzalloc() failure in check_perm()
check_perm() does not drop the reference to the module when kzalloc() failure occurs. Signed-Off-By: Chandra Seetharaman <sekharan@us.ibm.com> Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
This commit is contained in:
parent
e2057c5a63
commit
559c9ac391
|
@ -275,13 +275,14 @@ static int check_perm(struct inode * inode, struct file * file)
|
||||||
* it in file->private_data for easy access.
|
* it in file->private_data for easy access.
|
||||||
*/
|
*/
|
||||||
buffer = kzalloc(sizeof(struct configfs_buffer),GFP_KERNEL);
|
buffer = kzalloc(sizeof(struct configfs_buffer),GFP_KERNEL);
|
||||||
if (buffer) {
|
if (!buffer) {
|
||||||
init_MUTEX(&buffer->sem);
|
|
||||||
buffer->needs_read_fill = 1;
|
|
||||||
buffer->ops = ops;
|
|
||||||
file->private_data = buffer;
|
|
||||||
} else
|
|
||||||
error = -ENOMEM;
|
error = -ENOMEM;
|
||||||
|
goto Enomem;
|
||||||
|
}
|
||||||
|
init_MUTEX(&buffer->sem);
|
||||||
|
buffer->needs_read_fill = 1;
|
||||||
|
buffer->ops = ops;
|
||||||
|
file->private_data = buffer;
|
||||||
goto Done;
|
goto Done;
|
||||||
|
|
||||||
Einval:
|
Einval:
|
||||||
|
@ -289,6 +290,7 @@ static int check_perm(struct inode * inode, struct file * file)
|
||||||
goto Done;
|
goto Done;
|
||||||
Eaccess:
|
Eaccess:
|
||||||
error = -EACCES;
|
error = -EACCES;
|
||||||
|
Enomem:
|
||||||
module_put(attr->ca_owner);
|
module_put(attr->ca_owner);
|
||||||
Done:
|
Done:
|
||||||
if (error && item)
|
if (error && item)
|
||||||
|
|
Loading…
Reference in New Issue