The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Akinobu Mita <akinobu.mita@gmail.com>
To: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux-kernel@vger.kernel.org,
	Hoang-Nam Nguyen <hnguyen@de.ibm.com>,
	Christoph Raisch <raisch@de.ibm.com>,
	akpm@osdl.org
Subject: [PATCH -mm] return error on create_comp_task() failure
Date: Mon, 25 Dec 2006 17:13:47 +0900	[thread overview]
Message-ID: <20061225081347.GB3869@APFDCB5C> (raw)
In-Reply-To: <20061221212202.GA23157@osiris.ibm.com>

On Thu, Dec 21, 2006 at 10:22:02PM +0100, Heiko Carstens wrote:
> > @@ -730,7 +732,7 @@ int ehca_create_comp_pool(void)
> > 
> >  	for_each_online_cpu(cpu) {
> >  		task = create_comp_task(pool, cpu);
> > -		if (task) {
> > +		if (!IS_ERR(task)) {
> >  			kthread_bind(task, cpu);
> >  			wake_up_process(task);
> >  		}
> 
> So you silently ignore errors and the module loads anyway?

Subject: [PATCH -mm] return error on create_comp_task() failure

This patch frees allocated data and returns error
to avoid module loading if create_comp_task() failed.

Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Hoang-Nam Nguyen <hnguyen@de.ibm.com>
Cc: Christoph Raisch <raisch@de.ibm.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

---
 drivers/infiniband/hw/ehca/ehca_irq.c |   37 ++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)

Index: 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
===================================================================
--- 2.6-mm.orig/drivers/infiniband/hw/ehca/ehca_irq.c
+++ 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -716,11 +716,12 @@ static int comp_pool_callback(struct not
 
 #endif
 
+#ifdef CONFIG_INFINIBAND_EHCA_SCALING
+
 int ehca_create_comp_pool(void)
 {
-#ifdef CONFIG_INFINIBAND_EHCA_SCALING
 	int cpu;
-	struct task_struct *task;
+	int err;
 
 	pool = kzalloc(sizeof(struct ehca_comp_pool), GFP_KERNEL);
 	if (pool == NULL)
@@ -736,21 +737,41 @@ int ehca_create_comp_pool(void)
 	}
 
 	for_each_online_cpu(cpu) {
-		task = create_comp_task(pool, cpu);
-		if (!IS_ERR(task)) {
-			kthread_bind(task, cpu);
-			wake_up_process(task);
+		struct task_struct *task = create_comp_task(pool, cpu);
+
+		if (IS_ERR(task)) {
+			err = PTR_ERR(task);
+			goto err_comp_task;
 		}
+		kthread_bind(task, cpu);
+		wake_up_process(task);
 	}
 
 	comp_pool_callback_nb.notifier_call = comp_pool_callback;
-	comp_pool_callback_nb.priority =0;
+	comp_pool_callback_nb.priority = 0;
 	register_cpu_notifier(&comp_pool_callback_nb);
-#endif
 
 	return 0;
+
+err_comp_task:
+	for_each_online_cpu(cpu)
+		destroy_comp_task(pool, cpu);
+
+	free_percpu(pool->cpu_comp_tasks);
+	kfree(pool);
+
+	return err;
+}
+
+#else
+
+int ehca_create_comp_pool(void)
+{
+	return 0;
 }
 
+#endif
+
 void ehca_destroy_comp_pool(void)
 {
 #ifdef CONFIG_INFINIBAND_EHCA_SCALING

  parent reply	other threads:[~2006-12-25  8:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-19  8:42 [PATCH] ehca: fix kthread_create() error check Akinobu Mita
2006-12-19  9:32 ` Hoang-Nam Nguyen
2006-12-21 21:22 ` Heiko Carstens
2006-12-25  8:12   ` [PATCH -mm] ehca: avoid crash on kthread_create() failure Akinobu Mita
2006-12-25  8:30     ` Akinobu Mita
2006-12-25  8:55       ` Muli Ben-Yehuda
2006-12-25  9:35         ` Akinobu Mita
2006-12-25  9:41           ` Muli Ben-Yehuda
2006-12-25  9:58             ` Akinobu Mita
2006-12-25  8:13   ` Akinobu Mita [this message]
2006-12-25  8:14   ` [PATCH -mm] ehca: fix memleak on module unloading Akinobu Mita

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=20061225081347.GB3869@APFDCB5C \
    --to=akinobu.mita@gmail.com \
    --cc=akpm@osdl.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hnguyen@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=raisch@de.ibm.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