Commit 45a937a8 authored by Andy Whitcroft's avatar Andy Whitcroft Committed by Matt Fleming

efivarfs: efivarfs_create() ensure we drop our reference on inode on error

Signed-off-by: default avatarAndy Whitcroft <apw@canonical.com>
Acked-by: default avatarMatthew Garrett <mjg@redhat.com>
Acked-by: default avatarJeremy Kerr <jeremy.kerr@canonical.com>
Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
parent d142df03
...@@ -866,7 +866,7 @@ static void efivarfs_hex_to_guid(const char *str, efi_guid_t *guid) ...@@ -866,7 +866,7 @@ static void efivarfs_hex_to_guid(const char *str, efi_guid_t *guid)
static int efivarfs_create(struct inode *dir, struct dentry *dentry, static int efivarfs_create(struct inode *dir, struct dentry *dentry,
umode_t mode, bool excl) umode_t mode, bool excl)
{ {
struct inode *inode = efivarfs_get_inode(dir->i_sb, dir, mode, 0); struct inode *inode;
struct efivars *efivars = &__efivars; struct efivars *efivars = &__efivars;
struct efivar_entry *var; struct efivar_entry *var;
int namelen, i = 0, err = 0; int namelen, i = 0, err = 0;
...@@ -874,13 +874,15 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry, ...@@ -874,13 +874,15 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry,
if (dentry->d_name.len < 38) if (dentry->d_name.len < 38)
return -EINVAL; return -EINVAL;
inode = efivarfs_get_inode(dir->i_sb, dir, mode, 0);
if (!inode) if (!inode)
return -ENOSPC; return -ENOSPC;
var = kzalloc(sizeof(struct efivar_entry), GFP_KERNEL); var = kzalloc(sizeof(struct efivar_entry), GFP_KERNEL);
if (!var) {
if (!var) err = -ENOMEM;
return -ENOMEM; goto out;
}
namelen = dentry->d_name.len - GUID_LEN; namelen = dentry->d_name.len - GUID_LEN;
...@@ -908,8 +910,10 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry, ...@@ -908,8 +910,10 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry,
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
dget(dentry); dget(dentry);
out: out:
if (err) if (err) {
kfree(var); kfree(var);
iput(inode);
}
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment