[PATCH 2/3] efivarfs: fix memory leak on variable removal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



efivar_entry_delete() doesn't free the entry, it merely removes it
from the list.  Neither efivarfs_unlink(), nor efivarfs_file_write()
free the variable entry meaning it remains as unreferenced but
allocated memory.  Fix by adding the correct kfree()'s.

Signed-off-by: James Bottomley <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>
---
 fs/efivarfs/file.c  | 1 +
 fs/efivarfs/inode.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/fs/efivarfs/file.c b/fs/efivarfs/file.c
index 23c51d62f902..41b2f5a7239c 100644
--- a/fs/efivarfs/file.c
+++ b/fs/efivarfs/file.c
@@ -48,6 +48,7 @@ static ssize_t efivarfs_file_write(struct file *file,
 		drop_nlink(inode);
 		d_delete(file->f_path.dentry);
 		dput(file->f_path.dentry);
+		kfree(var);
 	} else {
 		inode_lock(inode);
 		i_size_write(inode, datasize + sizeof(attributes));
diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
index 586446e02ef7..37ff34fab9f7 100644
--- a/fs/efivarfs/inode.c
+++ b/fs/efivarfs/inode.c
@@ -143,6 +143,7 @@ static int efivarfs_unlink(struct inode *dir, struct dentry *dentry)
 
 	drop_nlink(d_inode(dentry));
 	dput(dentry);
+	kfree(var);
 	return 0;
 };
 
-- 
2.35.3





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux