From: Miaoqian Lin <linmq006@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Miaoqian Lin <linmq006@gmail.com>,
Mike Waychison <mikew@google.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] firmware: dmi-sysfs: Fix memory leak in dmi_system_event_log
Date: Thu, 20 Jan 2022 11:55:42 +0000 [thread overview]
Message-ID: <20220120115544.12239-1-linmq006@gmail.com> (raw)
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@gmail.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
reply other threads:[~2022-01-20 11:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220120115544.12239-1-linmq006@gmail.com \
--to=linmq006@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikew@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome