lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1433749777-9647-1-git-send-email-lin.z.chen@intel.com>
Date:	Mon,  8 Jun 2015 15:49:37 +0800
From:	Chen Lin Z <lin.z.chen@...el.com>
To:	gregkh@...uxfoundation.org
Cc:	linux-kernel@...r.kernel.org, bo.he@...el.com,
	yanmin_zhang@...ux.intel.com, Chen Lin Z <lin.z.chen@...el.com>
Subject: [PATCH] class: Free the kobject.name if kset_register fails

Fix a memory leak by freeing the memory allocated in kobject_set_name
for the kobjet name.

unreferenced object 0xe2167700 (size 64):
  comm "swapper/0", pid 1, jiffies 4294938161 (age 90.540s)
  hex dump (first 32 bytes):
    6d 61 67 6e 65 74 69 63 00 11 c2 c0 1f e9 23 c1  magnetic......#.
    18 00 00 00 04 66 9b e4 e0 66 9b e4 94 76 16 e2  .....f...f...v..
  backtrace:
    [<c0fb49dc>] kmemleak_alloc+0x3c/0xa0
    [<c0936cb5>] __kmalloc_track_caller+0x115/0x1d0
    [<c0b6b753>] kvasprintf+0x33/0x60
    [<c0b5fae2>] kobject_set_name_vargs+0x22/0x60
    [<c0b5fb31>] kobject_set_name+0x11/0x20
    [<c0c1f93e>] __class_register+0x8e/0x1e0
    [<c0c1fadb>] __class_create+0x4b/0x70
    [<c1417d61>] mmc3524x_init+0x18/0x97
    [<c080046c>] do_one_initcall+0xbc/0x190
    [<c13e0b47>] kernel_init_freeable+0xea/0x18c
    [<c0fb2fd0>] kernel_init+0x10/0xe0
    [<c0fc3337>] ret_from_kernel_thread+0x1b/0x28
    [<ffffffff>] 0xffffffff

Signed-off-by: Chen Lin Z <lin.z.chen@...el.com>
---
 drivers/base/class.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index 6e81088..f6e7f53 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -200,6 +200,7 @@ int __class_register(struct class *cls, struct lock_class_key *key)
 
 	error = kset_register(&cp->subsys);
 	if (error) {
+		kfree(cp->subsys.kobj.name);
 		kfree(cp);
 		return error;
 	}
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ