* [PATCH v3] mptbase: fixup error handling paths in mpt_attach()
@ 2016-02-23 14:00 Ewan D. Milne
2016-02-23 14:29 ` Johannes Thumshirn
2016-02-23 22:47 ` Martin K. Petersen
0 siblings, 2 replies; 4+ messages in thread
From: Ewan D. Milne @ 2016-02-23 14:00 UTC (permalink / raw)
To: linux-scsi, linux-kernel
Cc: wuninsu, thenzl, sreekanth.reddy, MPT-FusionLinux.pdl, taesoo,
yeongjin.jang, insu, changwoo
From: "Ewan D. Milne" <emilne@redhat.com>
mpt_attach() was not checking for the failure to create fw_event_q.
Also, iounmap() was not being called in all error cases after ioremap()
had been called by mpt_mapresources().
Reported-by: Insu Yun <wuninsu@gmail.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Ewan D. Milne <emilne@redhat.com>
---
drivers/message/fusion/mptbase.c | 40 +++++++++++++++++++++++++++++++++-------
1 file changed, 33 insertions(+), 7 deletions(-)
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 5dcc031..d3b130a 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1801,8 +1801,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
ioc->pcidev = pdev;
if (mpt_mapresources(ioc)) {
- kfree(ioc);
- return r;
+ goto out_free_ioc;
}
/*
@@ -1871,9 +1870,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 out_unmap_resources;
}
dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "facts @ %p, pfacts[0] @ %p\n",
@@ -1995,16 +1993,27 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
spin_lock_init(&ioc->fw_event_lock);
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) {
+ printk(MYIOC_s_ERR_FMT "Insufficient memory to add adapter!\n",
+ ioc->name);
+ r = -ENOMEM;
+ goto out_remove_ioc;
+ }
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);
+ destroy_workqueue(ioc->fw_event_q);
+ ioc->fw_event_q = NULL;
+
list_del(&ioc->list);
if (ioc->alt_ioc)
ioc->alt_ioc->alt_ioc = NULL;
iounmap(ioc->memmap);
+ if (pci_is_enabled(pdev))
+ pci_disable_device(pdev);
if (r != -5)
pci_release_selected_regions(pdev, ioc->bars);
@@ -2012,7 +2021,6 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
ioc->reset_work_q = NULL;
kfree(ioc);
- pci_set_drvdata(pdev, NULL);
return r;
}
@@ -2040,6 +2048,24 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
msecs_to_jiffies(MPT_POLLING_INTERVAL));
return 0;
+
+out_remove_ioc:
+ list_del(&ioc->list);
+ if (ioc->alt_ioc)
+ ioc->alt_ioc->alt_ioc = NULL;
+
+ destroy_workqueue(ioc->reset_work_q);
+ ioc->reset_work_q = NULL;
+
+out_unmap_resources:
+ iounmap(ioc->memmap);
+ pci_disable_device(pdev);
+ pci_release_selected_regions(pdev, ioc->bars);
+
+out_free_ioc:
+ kfree(ioc);
+
+ return r;
}
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -6229,7 +6255,7 @@ mpt_get_manufacturing_pg_0(MPT_ADAPTER *ioc)
memcpy(ioc->board_assembly, pbuf->BoardAssembly, sizeof(ioc->board_assembly));
memcpy(ioc->board_tracer, pbuf->BoardTracerNumber, sizeof(ioc->board_tracer));
- out:
+out:
if (pbuf)
pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, pbuf, buf_dma);
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] mptbase: fixup error handling paths in mpt_attach()
2016-02-23 14:00 [PATCH v3] mptbase: fixup error handling paths in mpt_attach() Ewan D. Milne
@ 2016-02-23 14:29 ` Johannes Thumshirn
2016-02-23 22:47 ` Martin K. Petersen
1 sibling, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2016-02-23 14:29 UTC (permalink / raw)
To: Ewan D. Milne
Cc: linux-scsi, linux-kernel, wuninsu, thenzl, sreekanth.reddy,
MPT-FusionLinux.pdl, taesoo, yeongjin.jang, insu, changwoo
On Tue, Feb 23, 2016 at 09:00:12AM -0500, Ewan D. Milne wrote:
> From: "Ewan D. Milne" <emilne@redhat.com>
>
> mpt_attach() was not checking for the failure to create fw_event_q.
> Also, iounmap() was not being called in all error cases after ioremap()
> had been called by mpt_mapresources().
>
> Reported-by: Insu Yun <wuninsu@gmail.com>
> Reviewed-by: Tomas Henzl <thenzl@redhat.com>
> Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] mptbase: fixup error handling paths in mpt_attach()
@ 2016-02-23 14:29 ` Johannes Thumshirn
0 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2016-02-23 14:29 UTC (permalink / raw)
To: Ewan D. Milne
Cc: linux-scsi, linux-kernel, wuninsu, thenzl, sreekanth.reddy,
MPT-FusionLinux.pdl, taesoo, yeongjin.jang, insu, changwoo
On Tue, Feb 23, 2016 at 09:00:12AM -0500, Ewan D. Milne wrote:
> From: "Ewan D. Milne" <emilne@redhat.com>
>
> mpt_attach() was not checking for the failure to create fw_event_q.
> Also, iounmap() was not being called in all error cases after ioremap()
> had been called by mpt_mapresources().
>
> Reported-by: Insu Yun <wuninsu@gmail.com>
> Reviewed-by: Tomas Henzl <thenzl@redhat.com>
> Signed-off-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] mptbase: fixup error handling paths in mpt_attach()
2016-02-23 14:00 [PATCH v3] mptbase: fixup error handling paths in mpt_attach() Ewan D. Milne
2016-02-23 14:29 ` Johannes Thumshirn
@ 2016-02-23 22:47 ` Martin K. Petersen
1 sibling, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2016-02-23 22:47 UTC (permalink / raw)
To: Ewan D. Milne
Cc: linux-scsi, linux-kernel, wuninsu, thenzl, sreekanth.reddy,
MPT-FusionLinux.pdl, taesoo, yeongjin.jang, insu, changwoo
>>>>> "Ewan" == Ewan D Milne <emilne@redhat.com> writes:
Ewan> mpt_attach() was not checking for the failure to create
Ewan> fw_event_q. Also, iounmap() was not being called in all error
Ewan> cases after ioremap() had been called by mpt_mapresources().
Applied to 4.6/scsi-queue.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-23 22:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-23 14:00 [PATCH v3] mptbase: fixup error handling paths in mpt_attach() Ewan D. Milne
2016-02-23 14:29 ` Johannes Thumshirn
2016-02-23 14:29 ` Johannes Thumshirn
2016-02-23 22:47 ` Martin K. Petersen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.