linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Cochran <rcochran@linutronix.de>
To: <linux-kernel@vger.kernel.org>
Cc: <rt@linutronix.de>, Len Brown <lenb@kernel.org>,
	linux-pm@vger.kernel.org
Subject: [PATCH 05/10] intel_idle: Fix dangling registration on error path.
Date: Tue, 29 Mar 2016 15:15:57 +0200	[thread overview]
Message-ID: <3a0f327af48507403d9ca332251e63a127efeb4b.1459257096.git.rcochran@linutronix.de> (raw)
In-Reply-To: <cover.1459257096.git.rcochran@linutronix.de>

In the module_init() method, if the per-CPU allocation fails, then the
active cpuidle registration is not cleaned up.  This patch fixes the
issue by attempting the allocation before registration, and then
cleaning it up again on registration failure.

Cc: Len Brown <lenb@kernel.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Richard Cochran <rcochran@linutronix.de>
---
 drivers/idle/intel_idle.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 4a1de3d..5dd741f 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -1210,19 +1210,20 @@ static int __init intel_idle_init(void)
 	if (retval)
 		return retval;
 
+	intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
+	if (intel_idle_cpuidle_devices == NULL)
+		return -ENOMEM;
+
 	intel_idle_cpuidle_driver_init();
 	retval = cpuidle_register_driver(&intel_idle_driver);
 	if (retval) {
 		struct cpuidle_driver *drv = cpuidle_get_driver();
 		printk(KERN_DEBUG PREFIX "intel_idle yielding to %s",
 			drv ? drv->name : "none");
+		free_percpu(intel_idle_cpuidle_devices);
 		return retval;
 	}
 
-	intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
-	if (intel_idle_cpuidle_devices == NULL)
-		return -ENOMEM;
-
 	cpu_notifier_register_begin();
 
 	for_each_online_cpu(i) {
-- 
2.1.4

  parent reply	other threads:[~2016-03-29 13:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-29 13:15 [PATCH 00/10] intel_idle: Fix hot plug handling Richard Cochran
2016-03-29 13:15 ` [PATCH 01/10] intel_idle: remove useless return from void function Richard Cochran
2016-03-29 13:15 ` [PATCH 02/10] intel_idle: Fix a helper function's return value Richard Cochran
2016-03-29 13:15 ` [PATCH 03/10] intel_idle: Remove redundant initialization calls Richard Cochran
2016-03-29 13:15 ` [PATCH 04/10] intel_idle: Fix deallocation order on the driver exit path Richard Cochran
2016-03-29 13:15 ` Richard Cochran [this message]
2016-03-29 13:15 ` [PATCH 06/10] intel_idle: Avoid a double free of the per-CPU data Richard Cochran
2016-03-29 13:15 ` [PATCH 07/10] intel_idle: Setup the timer broadcast only on successful driver load Richard Cochran
2016-03-29 13:16 ` [PATCH 08/10] intel_idle: Don't overreact to a cpuidle registration failure Richard Cochran
2016-03-29 13:16 ` [PATCH 09/10] intel_idle: Propagate hot plug errors Richard Cochran
2016-03-29 13:16 ` [PATCH 10/10] intel_idle: Clean up all registered devices on exit Richard Cochran
2016-04-01  1:39   ` Len Brown

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=3a0f327af48507403d9ca332251e63a127efeb4b.1459257096.git.rcochran@linutronix.de \
    --to=rcochran@linutronix.de \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rt@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).