linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Insu Yun <wuninsu@gmail.com>
To: nagalakshmi.nandigama@avagotech.com,
	praveen.krishnamoorthy@avagotech.com,
	sreekanth.reddy@avagotech.com, abhijit.mahajan@avagotech.com,
	MPT-FusionLinux.pdl@avagotech.com, linux-scsi@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 v2] fusion-mptbase: handle failed allocation for workqueue
Date: Wed, 17 Feb 2016 23:40:59 -0500	[thread overview]
Message-ID: <1455770459-905-1-git-send-email-wuninsu@gmail.com> (raw)

the failure of ioc->reset_work_q is checked,
but not ioc->fw_event_q.

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 drivers/message/fusion/mptbase.c | 44 ++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 5dcc031..53a5015 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1871,9 +1871,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (!ioc->reset_work_q) {
 		printk(MYIOC_s_ERR_FMT "Insufficient memory to add adapter!\n",
 		    ioc->name);
-		pci_release_selected_regions(pdev, ioc->bars);
-		kfree(ioc);
-		return -ENOMEM;
+		r = -ENOMEM;
+		goto err3;
 	}
 
 	dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "facts @ %p, pfacts[0] @ %p\n",
@@ -1996,24 +1995,16 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
 	snprintf(ioc->fw_event_q_name, MPT_KOBJ_NAME_LEN, "mpt/%d", ioc->id);
 	ioc->fw_event_q = create_singlethread_workqueue(ioc->fw_event_q_name);
 
+	if (!ioc->fw_event_q) {
+		r = -ENOMEM;
+		goto err2;
+	}
+
 	if ((r = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_BRINGUP,
 	    CAN_SLEEP)) != 0){
 		printk(MYIOC_s_ERR_FMT "didn't initialize properly! (%d)\n",
 		    ioc->name, r);
-
-		list_del(&ioc->list);
-		if (ioc->alt_ioc)
-			ioc->alt_ioc->alt_ioc = NULL;
-		iounmap(ioc->memmap);
-		if (r != -5)
-			pci_release_selected_regions(pdev, ioc->bars);
-
-		destroy_workqueue(ioc->reset_work_q);
-		ioc->reset_work_q = NULL;
-
-		kfree(ioc);
-		pci_set_drvdata(pdev, NULL);
-		return r;
+		goto err1;
 	}
 
 	/* call per device driver probe entry point */
@@ -2040,6 +2031,25 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
 			msecs_to_jiffies(MPT_POLLING_INTERVAL));
 
 	return 0;
+
+err1:
+		destroy_workqueue(ioc->fw_event_q);
+		ioc->fw_event_q = NULL;
+err2::
+		destroy_workqueue(ioc->reset_work_q);
+		ioc->reset_work_q = NULL;
+
+		list_del(&ioc->list);
+		if (ioc->alt_ioc)
+			ioc->alt_ioc->alt_ioc = NULL;
+		iounmap(ioc->memmap);
+		pci_set_drvdata(pdev, NULL);
+err3:
+		if (r != -5)
+			pci_release_selected_regions(pdev, ioc->bars);
+		kfree(ioc);
+		return r;
+
 }
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-- 
1.9.1

             reply	other threads:[~2016-02-18  4:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-18  4:40 Insu Yun [this message]
2016-02-18  9:00 ` [PATCH v2] fusion-mptbase: handle failed allocation for workqueue Johannes Thumshirn
2016-02-18 16:40   ` Ewan Milne
2016-02-18 16:55     ` Ewan Milne
2016-02-19 13:46       ` Tomas Henzl

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=1455770459-905-1-git-send-email-wuninsu@gmail.com \
    --to=wuninsu@gmail.com \
    --cc=MPT-FusionLinux.pdl@avagotech.com \
    --cc=abhijit.mahajan@avagotech.com \
    --cc=changwoo@gatech.edu \
    --cc=insu@gatech.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nagalakshmi.nandigama@avagotech.com \
    --cc=praveen.krishnamoorthy@avagotech.com \
    --cc=sreekanth.reddy@avagotech.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;
as well as URLs for NNTP newsgroup(s).