LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] firmware/dmi-sysfs: Fix a double free in dmi_sysfs_register_handle
@ 2021-03-22 13:30 Lv Yunlong
  0 siblings, 0 replies; only message in thread
From: Lv Yunlong @ 2021-03-22 13:30 UTC (permalink / raw
  To: akpm; +Cc: linux-kernel, Lv Yunlong

In the case of DMI_ENTRY_SYSTEM_EVENT_LOG, it calls
dmi_system_event_log(entry). If dmi_system_event_log()
failed, it will free the entry->child and return err.

But in the out_err branch, the entry->child will be freed
again. My patch adds a new label "out_err1" to avoid freeing
entry->child twice.

Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
---
 drivers/firmware/dmi-sysfs.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c
index 8b8127fa8955..fd498f2037a8 100644
--- a/drivers/firmware/dmi-sysfs.c
+++ b/drivers/firmware/dmi-sysfs.c
@@ -622,16 +622,17 @@ static void __init dmi_sysfs_register_handle(const struct dmi_header *dh,
 		break;
 	}
 	if (*ret)
-		goto out_err;
+		goto out_err1;
 
 	/* Create the raw binary file to access the entry */
 	*ret = sysfs_create_bin_file(&entry->kobj, &dmi_entry_raw_attr);
 	if (*ret)
-		goto out_err;
+		goto out_err2;
 
 	return;
-out_err:
+out_err2:
 	kobject_put(entry->child);
+out_err1:
 	kobject_put(&entry->kobj);
 	return;
 }
-- 
2.25.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-22 13:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-22 13:30 [PATCH] firmware/dmi-sysfs: Fix a double free in dmi_sysfs_register_handle Lv Yunlong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).