public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Insu Yun <wuninsu@gmail.com>
To: faisal.latif@intel.com, dledford@redhat.com,
	sean.hefty@intel.com, hal.rosenstock@gmail.com,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: taesoo@gatech.edu, yeongjin.jang@gatech.edu, insu@gatech.edu,
	changwoo@gatech.edu, Insu Yun <wuninsu@gmail.com>
Subject: [PATCH] nes: handling failed allocation when creating workqueue
Date: Wed, 17 Feb 2016 13:06:33 -0500	[thread overview]
Message-ID: <1455732393-11029-1-git-send-email-wuninsu@gmail.com> (raw)

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@gmail.com>
---
 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

             reply	other threads:[~2016-02-17 18:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-17 18:06 Insu Yun [this message]
     [not found] ` <1455732393-11029-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-02-18  4:59   ` [PATCH] nes: handling failed allocation when creating workqueue Leon Romanovsky
     [not found]     ` <20160218045905.GF30450-2ukJVAZIZ/Y@public.gmane.org>
2016-02-18 17:45       ` Doug Ledford

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=1455732393-11029-1-git-send-email-wuninsu@gmail.com \
    --to=wuninsu@gmail.com \
    --cc=changwoo@gatech.edu \
    --cc=dledford@redhat.com \
    --cc=faisal.latif@intel.com \
    --cc=hal.rosenstock@gmail.com \
    --cc=insu@gatech.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sean.hefty@intel.com \
    --cc=taesoo@gatech.edu \
    --cc=yeongjin.jang@gatech.edu \
    /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