aboutsummaryrefslogtreecommitdiffstats
path: root/fs/efivarfs
diff options
context:
space:
mode:
authorMatt Fleming <matt@codeblueprint.co.uk>2016-08-15 10:29:20 -0400
committerMatt Fleming <matt@codeblueprint.co.uk>2016-09-09 11:08:48 -0400
commit22c2b77f419bdc9317f00b395283abd33157368e (patch)
tree379db94c904ad0916c7cbc9d11c0f0d2fc77f6e1 /fs/efivarfs
parent0513fe1d28e45deb39159dbeedf0660c3f0effd2 (diff)
fs/efivarfs: Fix double kfree() in error path
Julia reported that we may double free 'name' in efivarfs_callback(), and that this bug was introduced by commit 0d22f33bc37c ("efi: Don't use spinlocks for efi vars"). Move one of the kfree()s until after the point at which we know we are definitely on the success path. Reported-by: Julia Lawall <julia.lawall@lip6.fr> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Sylvain Chouleur <sylvain.chouleur@gmail.com> Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Diffstat (limited to 'fs/efivarfs')
-rw-r--r--fs/efivarfs/super.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index 01e3d6e53944..d7a7c53803c1 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -157,14 +157,14 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
157 goto fail_inode; 157 goto fail_inode;
158 } 158 }
159 159
160 /* copied by the above to local storage in the dentry. */
161 kfree(name);
162
163 efivar_entry_size(entry, &size); 160 efivar_entry_size(entry, &size);
164 err = efivar_entry_add(entry, &efivarfs_list); 161 err = efivar_entry_add(entry, &efivarfs_list);
165 if (err) 162 if (err)
166 goto fail_inode; 163 goto fail_inode;
167 164
165 /* copied by the above to local storage in the dentry. */
166 kfree(name);
167
168 inode_lock(inode); 168 inode_lock(inode);
169 inode->i_private = entry; 169 inode->i_private = entry;
170 i_size_write(inode, size + sizeof(entry->var.Attributes)); 170 i_size_write(inode, size + sizeof(entry->var.Attributes));