mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arvind Yadav <arvind.yadav.cs@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] driver core: cpu: use put_device() if device_register fail
Date: Sun, 11 Mar 2018 11:25:51 +0530	[thread overview]
Message-ID: <4410a178df7ff0ea8f4b9a3639665c4f0386c3fe.1520747459.git.arvind.yadav.cs@gmail.com> (raw)
In-Reply-To: <cover.1520747459.git.arvind.yadav.cs@gmail.com>
In-Reply-To: <cover.1520747459.git.arvind.yadav.cs@gmail.com>

if device_register() returned an error! Always use put_device()
to give up the reference initialized.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/base/cpu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index d21a2d9..2da998b 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -382,8 +382,10 @@ int register_cpu(struct cpu *cpu, int num)
 	if (cpu->hotpluggable)
 		cpu->dev.groups = hotplugable_cpu_attr_groups;
 	error = device_register(&cpu->dev);
-	if (error)
+	if (error) {
+		put_device(&cpu->dev);
 		return error;
+	}
 
 	per_cpu(cpu_sys_devices, num) = &cpu->dev;
 	register_cpu_under_node(num, cpu_to_node(num));
-- 
2.7.4

      parent reply	other threads:[~2018-03-11  5:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-11  5:55 [PATCH 0/4] driver core: use put_device() instead of kfree() Arvind Yadav
2018-03-11  5:55 ` [PATCH 1/4] base: soc: " Arvind Yadav
2018-03-11  5:55 ` [PATCH 2/4] driver core: platform: use put_device() if device_register fail Arvind Yadav
2018-03-11  5:55 ` [PATCH 3/4] driver core: node: " Arvind Yadav
2018-03-11  5:55 ` Arvind Yadav [this message]

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=4410a178df7ff0ea8f4b9a3639665c4f0386c3fe.1520747459.git.arvind.yadav.cs@gmail.com \
    --to=arvind.yadav.cs@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /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®