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>] [day] [month] [year] [list]
Date:   Thu, 20 Jan 2022 11:55:42 +0000
From:   Miaoqian Lin <linmq006@...il.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Miaoqian Lin <linmq006@...il.com>,
        Mike Waychison <mikew@...gle.com>, linux-kernel@...r.kernel.org
Subject: [PATCH] firmware: dmi-sysfs: Fix memory leak in dmi_system_event_log

According to the doc of kobject_init_and_add():

   If this function returns an error, kobject_put() must be called to
   properly clean up the memory associated with the object.

Fix memory leak by calling kobject_put().
The callback function dmi_entry_free() in kobject_put()
will call kfree to handle the pointer.

Fixes: 925a1da7477f ("firmware: Break out system_event_log in dmi-sysfs")
Signed-off-by: Miaoqian Lin <linmq006@...il.com>
---
 drivers/firmware/dmi-sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c
index 3a353776bd34..d764fa578d66 100644
--- a/drivers/firmware/dmi-sysfs.c
+++ b/drivers/firmware/dmi-sysfs.c
@@ -458,7 +458,7 @@ static int dmi_system_event_log(struct dmi_sysfs_entry *entry)
 				   &entry->kobj,
 				   "system_event_log");
 	if (ret)
-		goto out_free;
+		goto out_put;
 
 	ret = sysfs_create_bin_file(entry->child, &dmi_sel_raw_attr);
 	if (ret)
@@ -468,8 +468,8 @@ static int dmi_system_event_log(struct dmi_sysfs_entry *entry)
 
 out_del:
 	kobject_del(entry->child);
-out_free:
-	kfree(entry->child);
+out_put:
+	kobject_put(entry->child);
 	return ret;
 }
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ