From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755290AbcBRFGl (ORCPT ); Thu, 18 Feb 2016 00:06:41 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:33658 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750854AbcBRFGj (ORCPT ); Thu, 18 Feb 2016 00:06:39 -0500 Date: Thu, 18 Feb 2016 06:59:05 +0200 From: Leon Romanovsky To: Insu Yun Cc: 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, taesoo@gatech.edu, yeongjin.jang@gatech.edu, insu@gatech.edu, changwoo@gatech.edu Subject: Re: [PATCH] nes: handling failed allocation when creating workqueue Message-ID: <20160218045905.GF30450@leon.nu> Reply-To: leon@leon.nu Mail-Followup-To: Insu Yun , 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, taesoo@gatech.edu, yeongjin.jang@gatech.edu, insu@gatech.edu, changwoo@gatech.edu References: <1455732393-11029-1-git-send-email-wuninsu@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1455732393-11029-1-git-send-email-wuninsu@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Please see my minor comments below. Reviewed-by: Leon Romanovsky On Wed, Feb 17, 2016 at 01:06:33PM -0500, Insu Yun wrote: > Since create_singlethread_workqueue uses kzalloc internally, > it can be failed in memory pressure, so need to handle it. s/can be failed/can fail/ > > Signed-off-by: Insu Yun > --- > 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; IMHO, there is no need to define goto label for one return. > > 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@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html