mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Allen Hung <allen_hung@dell.com>
To: Jean Delvare <jdelvare@suse.com>, linux-kernel@vger.kernel.org
Cc: Mario Limonciello <mario_limonciello@dell.com>,
	Allen Hung <allen_hung@dell.com>
Subject: [PATCH 1/2] dmi-id: don't free dev structure after calling device_register
Date: Fri, 15 Jul 2016 17:42:22 +0800	[thread overview]
Message-ID: <1468575743-26670-2-git-send-email-allen_hung@dell.com> (raw)
In-Reply-To: <1468575743-26670-1-git-send-email-allen_hung@dell.com>

dmi_dev is freed in error exit code but, according to the document
of device_register, it should never directly free device structure
after calling this function, even if it returned an error! Use
put_device() instead.

Signed-off-by: Allen Hung <allen_hung@dell.com>
---
 drivers/firmware/dmi-id.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
index 94a58a0..44c0139 100644
--- a/drivers/firmware/dmi-id.c
+++ b/drivers/firmware/dmi-id.c
@@ -229,14 +229,14 @@ static int __init dmi_id_init(void)
 
 	ret = device_register(dmi_dev);
 	if (ret)
-		goto fail_free_dmi_dev;
+		goto fail_put_dmi_dev;
 
 	return 0;
 
-fail_free_dmi_dev:
-	kfree(dmi_dev);
-fail_class_unregister:
+fail_put_dmi_dev:
+	put_device(dmi_dev);
 
+fail_class_unregister:
 	class_unregister(&dmi_class);
 
 	return ret;
-- 
2.7.4

  reply	other threads:[~2016-07-15  9:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-15  9:42 [PATCH 0/2] dmi-id: export oem strings to sysfs Allen Hung
2016-07-15  9:42 ` Allen Hung [this message]
2016-07-15  9:42 ` [PATCH 2/2] dmi-id: add dmi/id/oem group for exporting " Allen Hung
  -- strict thread matches above, loose matches on Subject: below --
2016-07-14  8:01 [PATCH 0/2] dmi-id: export " Allen Hung
2016-07-14  8:01 ` [PATCH 1/2] dmi-id: don't free dev structure after calling device_register Allen Hung
2016-07-18 17:09   ` Jean Delvare

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=1468575743-26670-2-git-send-email-allen_hung@dell.com \
    --to=allen_hung@dell.com \
    --cc=jdelvare@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario_limonciello@dell.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

all inboxes | Powered by JetHome®