Skip to contentSkip to conversation

ehca: fix kthread_create() error check

PATCH In review Akinobu Mita 4 participants 11 messages Dec 19, 2006 – Dec 25, 2006 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ehca: fix kthread_create() error check

The return value of kthread_create() should be checked by IS_ERR(). create_comp_task() returns the return value from kthread_create().

Cc Hoang-Nam Nguyen <[email protected]>
Cc Christoph Raisch <[email protected]>
---
 drivers/infiniband/hw/ehca/ehca_irq.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/hw/ehca/ehca_irq.c +4 -2
Index: 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
===================================================================
@@ -670,11 +670,13 @@ static int comp_pool_callback(struct not
 {
 	unsigned int cpu = (unsigned long)hcpu;
 	struct ehca_cpu_comp_task *cct;
+	struct task_struct *task;
 
 	switch (action) {
 	case CPU_UP_PREPARE:
 		ehca_gen_dbg("CPU: %x (CPU_PREPARE)", cpu);
-		if(!create_comp_task(pool, cpu)) {
+		task = create_comp_task(pool, cpu);
+		if (IS_ERR(task)) {
 			ehca_gen_err("Can't create comp_task for cpu: %x", cpu);
 			return NOTIFY_BAD;
 		}
@@ -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);
 		}
#1 lore raw

Hi,

Quoted 3 lines

The return value of kthread_create() should be checked by IS_ERR(). create_comp_task() returns the return value from kthread_create().

Good catch. Appreciate your help!
Regards
Nam

#2 lore raw
In reply to Akinobu Mita
Quoted 9 lines

Index: 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
===================================================================

drivers/infiniband/hw/ehca/ehca_irq.c +1 -0
@@ -670,11 +670,13 @@ static int comp_pool_callback(struct not
 {
 	unsigned int cpu = (unsigned long)hcpu;
 	struct ehca_cpu_comp_task *cct;
+	struct task_struct *task;

drivers/infiniband/hw/ehca/ehca_irq.c static int comp_pool_callback(struct not · line 682

Quoted 10 lines
drivers/infiniband/hw/ehca/ehca_irq.c +2 -1
 
 	switch (action) {
 	case CPU_UP_PREPARE:
 		ehca_gen_dbg("CPU: %x (CPU_PREPARE)", cpu);
-		if(!create_comp_task(pool, cpu)) {
+		task = create_comp_task(pool, cpu);
+		if (IS_ERR(task)) {
 			ehca_gen_err("Can't create comp_task for cpu: %x", cpu);
 			return NOTIFY_BAD;
 		}

If this fails then the code will crash on CPU_UP_CANCELED. Because of kthread_bind(cct->task,...). cct->task would be just the encoded error number.

drivers/infiniband/hw/ehca/ehca_irq.c int ehca_create_comp_pool(void) · line 738

Quoted 9 lines
drivers/infiniband/hw/ehca/ehca_irq.c +1 -1
@@ -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?

#3 lore raw

PATCH 1/1 ehca: avoid crash on kthread_create() failure

Quoted 10 lines · Heiko Carstens
Quoted 10 lines

Index: 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
===================================================================

drivers/infiniband/hw/ehca/ehca_irq.c +1 -0
@@ -670,11 +670,13 @@ static int comp_pool_callback(struct not
 {
 	unsigned int cpu = (unsigned long)hcpu;
 	struct ehca_cpu_comp_task *cct;
+	struct task_struct *task;
 
Quoted 13 lines

drivers/infiniband/hw/ehca/ehca_irq.c static int comp_pool_callback(struct not · line 682

Quoted 9 lines
drivers/infiniband/hw/ehca/ehca_irq.c +2 -1
 	switch (action) {
 	case CPU_UP_PREPARE:
 		ehca_gen_dbg("CPU: %x (CPU_PREPARE)", cpu);
-		if(!create_comp_task(pool, cpu)) {
+		task = create_comp_task(pool, cpu);
+		if (IS_ERR(task)) {
 			ehca_gen_err("Can't create comp_task for cpu: %x", cpu);
 			return NOTIFY_BAD;
 		}

If this fails then the code will crash on CPU_UP_CANCELED. Because of kthread_bind(cct->task,...). cct->task would be just the encoded error number.

Subject: [PATCH -mm] ehca: avoid crash on kthread_create() failure

This patch disallows invalid task_struct pointer returned by kthread_create() to be written to percpu data to avoid crash.

Cc Heiko Carstens <[email protected]>
Cc Hoang-Nam Nguyen <[email protected]>
Cc Christoph Raisch <[email protected]>
---
 drivers/infiniband/hw/ehca/ehca_irq.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/infiniband/hw/ehca/ehca_irq.c +8 -3
Index: 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
===================================================================
@@ -606,13 +606,16 @@ static int comp_task(void *__cct)
 static struct task_struct *create_comp_task(struct ehca_comp_pool *pool,
 					    int cpu)
 {
+	struct task_struct *task;
 	struct ehca_cpu_comp_task *cct;
 
 	cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);
 	spin_lock_init(&cct->task_lock);
 	INIT_LIST_HEAD(&cct->cq_list);
 	init_waitqueue_head(&cct->wait_queue);
-	cct->task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	if (!IS_ERR(task))
+		cct->task = task;
 
 	return cct->task;
 }
@@ -684,8 +687,10 @@ static int comp_pool_callback(struct not
 	case CPU_UP_CANCELED:
 		ehca_gen_dbg("CPU: %x (CPU_CANCELED)", cpu);
 		cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);
-		kthread_bind(cct->task, any_online_cpu(cpu_online_map));
-		destroy_comp_task(pool, cpu);
+		if (cct->task) {
+			kthread_bind(cct->task, any_online_cpu(cpu_online_map));
+			destroy_comp_task(pool, cpu);
+		}
 		break;
 	case CPU_ONLINE:
 		ehca_gen_dbg("CPU: %x (CPU_ONLINE)", cpu);
#4 lore raw

Re: [PATCH -mm] ehca: avoid crash on kthread_create() failure

Quoted 12 lines · Akinobu Mita

Index: 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
===================================================================

drivers/infiniband/hw/ehca/ehca_irq.c +1 -0
@@ -606,13 +606,16 @@ static int comp_task(void *__cct)
 static struct task_struct *create_comp_task(struct ehca_comp_pool *pool,
 					    int cpu)
 {
+	struct task_struct *task;
 	struct ehca_cpu_comp_task *cct;
 
 	cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);

drivers/infiniband/hw/ehca/ehca_irq.c static int comp_task(void *__cct) · line 621

Quoted 10 lines
drivers/infiniband/hw/ehca/ehca_irq.c +3 -1
 	spin_lock_init(&cct->task_lock);
 	INIT_LIST_HEAD(&cct->cq_list);
 	init_waitqueue_head(&cct->wait_queue);
-	cct->task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	if (!IS_ERR(task))
+		cct->task = task;
 
 	return cct->task;
 }

This patch is wrong. It changes to make create_comp_task() return NULL on failure.

(BTW, all these ehca fixes are not compile tested due to luck of cross comile environment)

Subject: [PATCH -mm] ehca: avoid crash on kthread_create() failure (v2)

This patch disallows invalid task_struct pointer returned by kthread_create() to be written to percpu data to avoid crash.

Cc Heiko Carstens <[email protected]>
Cc Hoang-Nam Nguyen <[email protected]>
Cc Christoph Raisch <[email protected]>
---
 drivers/infiniband/hw/ehca/ehca_irq.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/infiniband/hw/ehca/ehca_irq.c +9 -4
Index: 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
===================================================================
@@ -606,15 +606,18 @@ static int comp_task(void *__cct)
 static struct task_struct *create_comp_task(struct ehca_comp_pool *pool,
 					    int cpu)
 {
+	struct task_struct *task;
 	struct ehca_cpu_comp_task *cct;
 
 	cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);
 	spin_lock_init(&cct->task_lock);
 	INIT_LIST_HEAD(&cct->cq_list);
 	init_waitqueue_head(&cct->wait_queue);
-	cct->task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	if (!IS_ERR(task))
+		cct->task = task;
 
-	return cct->task;
+	return task;
 }
 
 static void destroy_comp_task(struct ehca_comp_pool *pool,
@@ -684,8 +687,10 @@ static int comp_pool_callback(struct not
 	case CPU_UP_CANCELED:
 		ehca_gen_dbg("CPU: %x (CPU_CANCELED)", cpu);
 		cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);
-		kthread_bind(cct->task, any_online_cpu(cpu_online_map));
-		destroy_comp_task(pool, cpu);
+		if (cct->task) {
+			kthread_bind(cct->task, any_online_cpu(cpu_online_map));
+			destroy_comp_task(pool, cpu);
+		}
 		break;
 	case CPU_ONLINE:
 		ehca_gen_dbg("CPU: %x (CPU_ONLINE)", cpu);
#5 lore raw

Re: [PATCH -mm] ehca: avoid crash on kthread_create() failure

Quoted 70 lines · Akinobu Mita
Quoted 12 lines · Akinobu Mita

Index: 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
===================================================================

drivers/infiniband/hw/ehca/ehca_irq.c +1 -0
@@ -606,13 +606,16 @@ static int comp_task(void *__cct)
 static struct task_struct *create_comp_task(struct ehca_comp_pool *pool,
 					    int cpu)
 {
+	struct task_struct *task;
 	struct ehca_cpu_comp_task *cct;
 
 	cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);

drivers/infiniband/hw/ehca/ehca_irq.c static int comp_task(void *__cct) · line 621

Quoted 10 lines
drivers/infiniband/hw/ehca/ehca_irq.c +3 -1
 	spin_lock_init(&cct->task_lock);
 	INIT_LIST_HEAD(&cct->cq_list);
 	init_waitqueue_head(&cct->wait_queue);
-	cct->task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	if (!IS_ERR(task))
+		cct->task = task;
 
 	return cct->task;
 }

This patch is wrong. It changes to make create_comp_task() return NULL on failure.

(BTW, all these ehca fixes are not compile tested due to luck of cross comile environment)

Subject: [PATCH -mm] ehca: avoid crash on kthread_create() failure (v2)

This patch disallows invalid task_struct pointer returned by kthread_create() to be written to percpu data to avoid crash.

Cc Heiko Carstens <[email protected]>
Cc Hoang-Nam Nguyen <[email protected]>
Cc Christoph Raisch <[email protected]>
---
 drivers/infiniband/hw/ehca/ehca_irq.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Index: 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
===================================================================

drivers/infiniband/hw/ehca/ehca_irq.c +5 -2
@@ -606,15 +606,18 @@ static int comp_task(void *__cct)
 static struct task_struct *create_comp_task(struct ehca_comp_pool *pool,
 					    int cpu)
 {
+	struct task_struct *task;
 	struct ehca_cpu_comp_task *cct;
 
 	cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);
 	spin_lock_init(&cct->task_lock);
 	INIT_LIST_HEAD(&cct->cq_list);
 	init_waitqueue_head(&cct->wait_queue);
-	cct->task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	if (!IS_ERR(task))
+		cct->task = task;
 
-	return cct->task;
+	return task;
 }
 
 static void destroy_comp_task(struct ehca_comp_pool *pool,

drivers/infiniband/hw/ehca/ehca_irq.c static int comp_pool_callback(struct not · line 693

Quoted 9 lines
drivers/infiniband/hw/ehca/ehca_irq.c +4 -2
@@ -684,8 +687,10 @@ static int comp_pool_callback(struct not
 	case CPU_UP_CANCELED:
 		ehca_gen_dbg("CPU: %x (CPU_CANCELED)", cpu);
 		cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);
-		kthread_bind(cct->task, any_online_cpu(cpu_online_map));
-		destroy_comp_task(pool, cpu);
+		if (cct->task) {
+			kthread_bind(cct->task, any_online_cpu(cpu_online_map));
+			destroy_comp_task(pool, cpu);
+		}

This is correct because cct is allocated via alloc_percpu, which in turn calls kzalloc, which means cct->task is NULL by default, but it's a little too obscure for me. How about making it explicit?

task = kthread_create(...)
if (!IS_ERR(task))
cct->task = task;
else
cct->task = NULL;

return cct->task;

Cheers,
Muli

#6 lore raw

Re: [PATCH -mm] ehca: avoid crash on kthread_create() failure

Quoted 11 lines · Muli Ben-Yehuda

This is correct because cct is allocated via alloc_percpu, which in turn calls kzalloc, which means cct->task is NULL by default, but it's a little too obscure for me. How about making it explicit?

task = kthread_create(...)
if (!IS_ERR(task))
cct->task = task;
else
cct->task = NULL;

return cct->task;

Subject: [PATCH -mm] ehca: avoid crash on kthread_create() failure (v3)

This patch disallows invalid task_struct pointer returned by kthread_create() to be written to percpu data to avoid crash.

Cc Heiko Carstens <[email protected]>
Cc Hoang-Nam Nguyen <[email protected]>
Cc Christoph Raisch <[email protected]>
---
 drivers/infiniband/hw/ehca/ehca_irq.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/infiniband/hw/ehca/ehca_irq.c +11 -4
Index: 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
===================================================================
@@ -606,15 +606,20 @@ static int comp_task(void *__cct)
 static struct task_struct *create_comp_task(struct ehca_comp_pool *pool,
 					    int cpu)
 {
+	struct task_struct *task;
 	struct ehca_cpu_comp_task *cct;
 
 	cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);
 	spin_lock_init(&cct->task_lock);
 	INIT_LIST_HEAD(&cct->cq_list);
 	init_waitqueue_head(&cct->wait_queue);
-	cct->task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	if (!IS_ERR(task))
+		cct->task = task;
+	else
+		cct->task = NULL;
 
-	return cct->task;
+	return task;
 }
 
 static void destroy_comp_task(struct ehca_comp_pool *pool,
@@ -684,8 +689,10 @@ static int comp_pool_callback(struct not
 	case CPU_UP_CANCELED:
 		ehca_gen_dbg("CPU: %x (CPU_CANCELED)", cpu);
 		cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);
-		kthread_bind(cct->task, any_online_cpu(cpu_online_map));
-		destroy_comp_task(pool, cpu);
+		if (cct->task) {
+			kthread_bind(cct->task, any_online_cpu(cpu_online_map));
+			destroy_comp_task(pool, cpu);
+		}
 		break;
 	case CPU_ONLINE:
 		ehca_gen_dbg("CPU: %x (CPU_ONLINE)", cpu);
#7 lore raw

Re: [PATCH -mm] ehca: avoid crash on kthread_create() failure

Quoted 41 lines · Akinobu Mita
Quoted 11 lines · Muli Ben-Yehuda

This is correct because cct is allocated via alloc_percpu, which in turn calls kzalloc, which means cct->task is NULL by default, but it's a little too obscure for me. How about making it explicit?

task = kthread_create(...)
if (!IS_ERR(task))
cct->task = task;
else
cct->task = NULL;

return cct->task;

Subject: [PATCH -mm] ehca: avoid crash on kthread_create() failure (v3)

This patch disallows invalid task_struct pointer returned by kthread_create() to be written to percpu data to avoid crash.

Cc Heiko Carstens <[email protected]>
Cc Hoang-Nam Nguyen <[email protected]>
Cc Christoph Raisch <[email protected]>
---
 drivers/infiniband/hw/ehca/ehca_irq.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Index: 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
===================================================================

drivers/infiniband/hw/ehca/ehca_irq.c +1 -0
@@ -606,15 +606,20 @@ static int comp_task(void *__cct)
 static struct task_struct *create_comp_task(struct ehca_comp_pool *pool,
 					    int cpu)
 {
+	struct task_struct *task;
 	struct ehca_cpu_comp_task *cct;
 
 	cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);
 	spin_lock_init(&cct->task_lock);
 	INIT_LIST_HEAD(&cct->cq_list);

drivers/infiniband/hw/ehca/ehca_irq.c static int comp_task(void *__cct) · line 622

Quoted 10 lines
drivers/infiniband/hw/ehca/ehca_irq.c +6 -2
 	init_waitqueue_head(&cct->wait_queue);
-	cct->task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	if (!IS_ERR(task))
+		cct->task = task;
+	else
+		cct->task = NULL;
 
-	return cct->task;
+	return task;

This should be return cct->task, since we later test the return value of create_comp_task against NULL, e.g., in comp_poll_callback and ehca_create_comp_pool.

Cheers,
Muli

#8 lore raw

Re: [PATCH -mm] ehca: avoid crash on kthread_create() failure

Quoted 50 lines · Muli Ben-Yehuda
Quoted 49 lines · Akinobu Mita
Quoted 11 lines · Muli Ben-Yehuda

This is correct because cct is allocated via alloc_percpu, which in turn calls kzalloc, which means cct->task is NULL by default, but it's a little too obscure for me. How about making it explicit?

task = kthread_create(...)
if (!IS_ERR(task))
cct->task = task;
else
cct->task = NULL;

return cct->task;

Subject: [PATCH -mm] ehca: avoid crash on kthread_create() failure (v3)

This patch disallows invalid task_struct pointer returned by kthread_create() to be written to percpu data to avoid crash.

Cc Heiko Carstens <[email protected]>
Cc Hoang-Nam Nguyen <[email protected]>
Cc Christoph Raisch <[email protected]>
---
 drivers/infiniband/hw/ehca/ehca_irq.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Index: 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
===================================================================

drivers/infiniband/hw/ehca/ehca_irq.c +6 -1
@@ -606,15 +606,20 @@ static int comp_task(void *__cct)
 static struct task_struct *create_comp_task(struct ehca_comp_pool *pool,
 					    int cpu)
 {
+	struct task_struct *task;
 	struct ehca_cpu_comp_task *cct;
 
 	cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);
 	spin_lock_init(&cct->task_lock);
 	INIT_LIST_HEAD(&cct->cq_list);
 	init_waitqueue_head(&cct->wait_queue);
-	cct->task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	task = kthread_create(comp_task, cct, "ehca_comp/%d", cpu);
+	if (!IS_ERR(task))
+		cct->task = task;
+	else
+		cct->task = NULL;
 
Quoted 6 lines

drivers/infiniband/hw/ehca/ehca_irq.c static int comp_task(void *__cct) · line 622

Quoted 2 lines
drivers/infiniband/hw/ehca/ehca_irq.c +1 -1
-	return cct->task;
+	return task;

This should be return cct->task, since we later test the return value of create_comp_task against NULL, e.g., in comp_poll_callback and ehca_create_comp_pool.

Yeah, I already sent the patch:
http://lkml.org/lkml/2006/12/19/56

Maybe I should reorganize these ehca fixes later.
(make ehca_create_task() return NULL on failure)

#9 lore raw

PATCH 1/1 return error on create_comp_task() failure

In reply to Heiko Carstens
Quoted 11 lines · Heiko Carstens

Review int ehca_create_comp_pool(void) · line 738

Quoted 9 lines
(quoted diff) +1 -1
@@ -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 <[email protected]>
Cc Hoang-Nam Nguyen <[email protected]>
Cc Christoph Raisch <[email protected]>
---
 drivers/infiniband/hw/ehca/ehca_irq.c |   37 ++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)
drivers/infiniband/hw/ehca/ehca_irq.c +29 -8
Index: 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
#10 lore raw

PATCH 1/1 ehca: fix memleak on module unloading

In reply to Heiko Carstens

Subject: [PATCH] ehca: fix memleak on module unloading

percpu data is not freed on module unloading.

Cc Heiko Carstens <[email protected]>
Cc Hoang-Nam Nguyen <[email protected]>
Cc Christoph Raisch <[email protected]>
---
 drivers/infiniband/hw/ehca/ehca_irq.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/infiniband/hw/ehca/ehca_irq.c +2 -0
Index: 2.6-mm/drivers/infiniband/hw/ehca/ehca_irq.c
===================================================================
@@ -757,6 +757,8 @@ void ehca_destroy_comp_pool(void)
 		if (cpu_online(i))
 			destroy_comp_task(pool, i);
 	}
+	free_percpu(pool->cpu_comp_tasks);
+	kfree(pool);
 #endif
 
 	return;