Skip to content

Commit 22c2b77

Browse files
committed
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 0d22f33 ("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>
1 parent 0513fe1 commit 22c2b77

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/efivarfs/super.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
157157
goto fail_inode;
158158
}
159159

160-
/* copied by the above to local storage in the dentry. */
161-
kfree(name);
162-
163160
efivar_entry_size(entry, &size);
164161
err = efivar_entry_add(entry, &efivarfs_list);
165162
if (err)
166163
goto fail_inode;
167164

165+
/* copied by the above to local storage in the dentry. */
166+
kfree(name);
167+
168168
inode_lock(inode);
169169
inode->i_private = entry;
170170
i_size_write(inode, size + sizeof(entry->var.Attributes));

0 commit comments

Comments
 (0)