Commit-ID: 22c2b77f419bdc9317f00b395283abd33157368e Gitweb: http://git.kernel.org/tip/22c2b77f419bdc9317f00b395283abd33157368e Author: Matt Fleming <matt@xxxxxxxxxxxxxxxxxxx> AuthorDate: Mon, 15 Aug 2016 15:29:20 +0100 Committer: Matt Fleming <matt@xxxxxxxxxxxxxxxxxxx> CommitDate: Fri, 9 Sep 2016 16:08:48 +0100 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@xxxxxxx> Acked-by: Julia Lawall <julia.lawall@xxxxxxx> Cc: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx> Cc: Sylvain Chouleur <sylvain.chouleur@xxxxxxxxx> Signed-off-by: Matt Fleming <matt@xxxxxxxxxxxxxxxxxxx> --- fs/efivarfs/super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c index 01e3d6e..d7a7c53 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, goto fail_inode; } - /* copied by the above to local storage in the dentry. */ - kfree(name); - efivar_entry_size(entry, &size); err = efivar_entry_add(entry, &efivarfs_list); if (err) goto fail_inode; + /* copied by the above to local storage in the dentry. */ + kfree(name); + inode_lock(inode); inode->i_private = entry; i_size_write(inode, size + sizeof(entry->var.Attributes)); -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
![]() |