Skip to content

Commit ff04f3b

Browse files
committed
efivarfs: revert "fix memory leak in efivarfs_create()"
The memory leak addressed by commit fe5186c is a false positive: all allocations are recorded in a linked list, and freed when the filesystem is unmounted. This leads to double frees, and as reported by David, leads to crashes if SLUB is configured to self destruct when double frees occur. So drop the redundant kfree() again, and instead, mark the offending pointer variable so the allocation is ignored by kmemleak. Cc: Vamshi K Sthambamkadi <[email protected]> Fixes: fe5186c ("efivarfs: fix memory leak in efivarfs_create()") Reported-by: David Laight <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 50bdcf0 commit ff04f3b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

fs/efivarfs/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/efi.h>
88
#include <linux/fs.h>
99
#include <linux/ctype.h>
10+
#include <linux/kmemleak.h>
1011
#include <linux/slab.h>
1112
#include <linux/uuid.h>
1213

@@ -103,6 +104,7 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry,
103104
var->var.VariableName[i] = '\0';
104105

105106
inode->i_private = var;
107+
kmemleak_ignore(var);
106108

107109
err = efivar_entry_add(var, &efivarfs_list);
108110
if (err)

fs/efivarfs/super.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ LIST_HEAD(efivarfs_list);
2121
static void efivarfs_evict_inode(struct inode *inode)
2222
{
2323
clear_inode(inode);
24-
kfree(inode->i_private);
2524
}
2625

2726
static const struct super_operations efivarfs_ops = {

0 commit comments

Comments
 (0)