From: Chandra Seetharaman Date: Tue, 10 Oct 2006 22:15:55 +0000 (-0700) Subject: configfs: handle kzalloc() failure in check_perm() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=559c9ac391c046710bdeee5581dc5d9dda794881;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.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 Signed-off-by: Joel Becker Signed-off-by: Mark Fasheh --- diff --git a/fs/configfs/file.c b/fs/configfs/file.c index e6d5754a715e..cf33fac68c84 100644 --- a/fs/configfs/file.c +++ b/fs/configfs/file.c @@ -275,13 +275,14 @@ static int check_perm(struct inode * inode, struct file * file) * it in file->private_data for easy access. */ buffer = kzalloc(sizeof(struct configfs_buffer),GFP_KERNEL); - if (buffer) { - init_MUTEX(&buffer->sem); - buffer->needs_read_fill = 1; - buffer->ops = ops; - file->private_data = buffer; - } else + if (!buffer) { error = -ENOMEM; + goto Enomem; + } + init_MUTEX(&buffer->sem); + buffer->needs_read_fill = 1; + buffer->ops = ops; + file->private_data = buffer; goto Done; Einval: @@ -289,6 +290,7 @@ static int check_perm(struct inode * inode, struct file * file) goto Done; Eaccess: error = -EACCES; + Enomem: module_put(attr->ca_owner); Done: if (error && item)