From 8007f10259d04f37044c2c731bf9ccdd9161d825 Mon Sep 17 00:00:00 2001 From: Xiaotian Feng Date: Tue, 9 Feb 2010 08:22:24 +1100 Subject: selinux: fix memory leak in sel_make_bools In sel_make_bools, kernel allocates memory for bool_pending_names[i] with security_get_bools. So if we just free bool_pending_names, those memories for bool_pending_names[i] will be leaked. This patch resolves dozens of following kmemleak report after resuming from suspend: unreferenced object 0xffff88022e4c7380 (size 32): comm "init", pid 1, jiffies 4294677173 backtrace: [] create_object+0x1a2/0x2a9 [] kmemleak_alloc+0x26/0x4b [] __kmalloc+0x18f/0x1b8 [] security_get_bools+0xd7/0x16f [] sel_write_load+0x12e/0x62b [] vfs_write+0xae/0x10b [] sys_write+0x4a/0x6e [] system_call_fastpath+0x16/0x1b [] 0xffffffffffffffff Signed-off-by: Xiaotian Feng Signed-off-by: James Morris --- security/selinux/selinuxfs.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'security') diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index a1cfc464bbb..cd191bbec03 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c @@ -977,6 +977,8 @@ static int sel_make_bools(void) u32 sid; /* remove any existing files */ + for (i = 0; i < bool_num; i++) + kfree(bool_pending_names[i]); kfree(bool_pending_names); kfree(bool_pending_values); bool_pending_names = NULL; -- cgit v1.2.3