mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-30 19:06:14 +00:00
efivarfs: return accurate error code in efivarfs_fill_super()
Joseph was hitting a failure case when mounting efivarfs which resulted in an incorrect error message, $ sudo mount -v /sys/firmware/efi/efivars mount: Cannot allocate memory triggered when efivarfs_valid_name() returned -EINVAL. Make sure we pass accurate return values up the stack if efivarfs_fill_super() fails to build inodes for EFI variables. Reported-by: Joseph Yasi <joe.yasi@gmail.com> Reported-by: Lingzhu Xiang <lxiang@redhat.com> Cc: Josh Boyer <jwboyer@redhat.com> Cc: Jeremy Kerr <jk@ozlabs.org> Cc: Matthew Garrett <mjg59@srcf.ucam.org> Cc: <stable@vger.kernel.org> # v3.8 Signed-off-by: Matt Fleming <matt.fleming@intel.com>
This commit is contained in:
parent
123abd76ed
commit
feff5dc4f9
1 changed files with 15 additions and 5 deletions
|
@ -1163,15 +1163,22 @@ static struct dentry_operations efivarfs_d_ops = {
|
||||||
|
|
||||||
static struct dentry *efivarfs_alloc_dentry(struct dentry *parent, char *name)
|
static struct dentry *efivarfs_alloc_dentry(struct dentry *parent, char *name)
|
||||||
{
|
{
|
||||||
|
struct dentry *d;
|
||||||
struct qstr q;
|
struct qstr q;
|
||||||
|
int err;
|
||||||
|
|
||||||
q.name = name;
|
q.name = name;
|
||||||
q.len = strlen(name);
|
q.len = strlen(name);
|
||||||
|
|
||||||
if (efivarfs_d_hash(NULL, NULL, &q))
|
err = efivarfs_d_hash(NULL, NULL, &q);
|
||||||
return NULL;
|
if (err)
|
||||||
|
return ERR_PTR(err);
|
||||||
|
|
||||||
return d_alloc(parent, &q);
|
d = d_alloc(parent, &q);
|
||||||
|
if (d)
|
||||||
|
return d;
|
||||||
|
|
||||||
|
return ERR_PTR(-ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int efivarfs_fill_super(struct super_block *sb, void *data, int silent)
|
static int efivarfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
|
@ -1181,6 +1188,7 @@ static int efivarfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
struct efivar_entry *entry, *n;
|
struct efivar_entry *entry, *n;
|
||||||
struct efivars *efivars = &__efivars;
|
struct efivars *efivars = &__efivars;
|
||||||
char *name;
|
char *name;
|
||||||
|
int err = -ENOMEM;
|
||||||
|
|
||||||
efivarfs_sb = sb;
|
efivarfs_sb = sb;
|
||||||
|
|
||||||
|
@ -1231,8 +1239,10 @@ static int efivarfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||||
goto fail_name;
|
goto fail_name;
|
||||||
|
|
||||||
dentry = efivarfs_alloc_dentry(root, name);
|
dentry = efivarfs_alloc_dentry(root, name);
|
||||||
if (!dentry)
|
if (IS_ERR(dentry)) {
|
||||||
|
err = PTR_ERR(dentry);
|
||||||
goto fail_inode;
|
goto fail_inode;
|
||||||
|
}
|
||||||
|
|
||||||
/* copied by the above to local storage in the dentry. */
|
/* copied by the above to local storage in the dentry. */
|
||||||
kfree(name);
|
kfree(name);
|
||||||
|
@ -1259,7 +1269,7 @@ fail_inode:
|
||||||
fail_name:
|
fail_name:
|
||||||
kfree(name);
|
kfree(name);
|
||||||
fail:
|
fail:
|
||||||
return -ENOMEM;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dentry *efivarfs_mount(struct file_system_type *fs_type,
|
static struct dentry *efivarfs_mount(struct file_system_type *fs_type,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue