[PATCH] nes: handling failed allocation when creating workqueue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since create_singlethread_workqueue uses kzalloc internally, 
it can be failed in memory pressure, so need to handle it.

Signed-off-by: Insu Yun <wuninsu@xxxxxxxxx>
---
 drivers/infiniband/hw/nes/nes_cm.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index cb9f0f2..23afad6 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -2833,7 +2833,7 @@ static struct nes_cm_core *nes_cm_alloc_core(void)
 	/* alloc top level core control structure */
 	cm_core = kzalloc(sizeof(*cm_core), GFP_KERNEL);
 	if (!cm_core)
-		return NULL;
+		goto enomem_3;
 
 	INIT_LIST_HEAD(&cm_core->connected_nodes);
 	init_timer(&cm_core->tcp_timer);
@@ -2856,12 +2856,23 @@ static struct nes_cm_core *nes_cm_alloc_core(void)
 
 	nes_debug(NES_DBG_CM, "Enable QUEUE EVENTS\n");
 	cm_core->event_wq = create_singlethread_workqueue("nesewq");
+	if (!cm_core->event_wq)
+		goto enomem_2;
 	cm_core->post_event = nes_cm_post_event;
 	nes_debug(NES_DBG_CM, "Enable QUEUE DISCONNECTS\n");
 	cm_core->disconn_wq = create_singlethread_workqueue("nesdwq");
+	if (!cm_core->disconn_wq)
+		goto enomem_1;
 
 	print_core(cm_core);
 	return cm_core;
+
+enomem_1:
+	destroy_workqueue(cm_core->event_wq);
+enomem_2:
+	kfree(cm_core);
+enomem_3:
+	return NULL;
 }
 
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux