linux-stable/drivers/scsi/lpfc
James Smart 5fc77964ea scsi: lpfc: Fix crash after bad bar setup on driver attachment
commit e4b9794efd upstream.

In test cases where an instance of the driver is detached and
reattached, the driver will crash on reattachment. There is a compound
if statement that will skip over the bar setup if the pci_resource_start
call is not successful. The driver erroneously returns success to its
bar setup in this scenario even though the bars aren't properly
configured.

Rework the offending code segment for proper initialization steps.  If
the pci_resource_start call fails, -ENOMEM is now returned.

Sample stack:

rport-5:0-10: blocked FC remote port time out: removing rport
BUG: unable to handle kernel NULL pointer dereference at           (null)
... lpfc_sli4_wait_bmbx_ready+0x32/0x70 [lpfc]
...
...  RIP: 0010:...  ... lpfc_sli4_wait_bmbx_ready+0x32/0x70 [lpfc]
 Call Trace:
  ... lpfc_sli4_post_sync_mbox+0x106/0x4d0 [lpfc]
  ... ? __alloc_pages_nodemask+0x176/0x420
  ... ? __kmalloc+0x2e/0x230
  ... lpfc_sli_issue_mbox_s4+0x533/0x720 [lpfc]
  ... ? mempool_alloc+0x69/0x170
  ... ? dma_generic_alloc_coherent+0x8f/0x140
  ... lpfc_sli_issue_mbox+0xf/0x20 [lpfc]
  ... lpfc_sli4_driver_resource_setup+0xa6f/0x1130 [lpfc]
  ... ? lpfc_pci_probe_one+0x23e/0x16f0 [lpfc]
  ... lpfc_pci_probe_one+0x445/0x16f0 [lpfc]
  ... local_pci_probe+0x45/0xa0
  ... work_for_cpu_fn+0x14/0x20
  ... process_one_work+0x17a/0x440

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-02-16 20:23:11 +01:00
..
lpfc.h scsi: lpfc: Add Buffer to Buffer credit recovery support 2017-08-24 22:29:43 -04:00
lpfc_attr.c scsi: lpfc: Fix crash receiving ELS while detaching driver 2017-11-30 08:40:50 +00:00
lpfc_attr.h scsi: lpfc: Add Buffer to Buffer credit recovery support 2017-08-24 22:29:43 -04:00
lpfc_bsg.c scsi: lpfc: Fix crash receiving ELS while detaching driver 2017-11-30 08:40:50 +00:00
lpfc_bsg.h scsi: lpfc: Update copyrights 2017-02-22 18:41:44 -05:00
lpfc_compat.h scsi: lpfc: Update copyrights 2017-02-22 18:41:44 -05:00
lpfc_crtn.h scsi: lpfc: Fix MRQ > 1 context list handling 2017-08-24 22:29:41 -04:00
lpfc_ct.c scsi: lpfc: convert info messages to standard messages 2017-08-24 22:29:36 -04:00
lpfc_debugfs.c SCSI misc on 20170907 2017-09-07 21:11:05 -07:00
lpfc_debugfs.h scsi: lpfc: avoid false-positive gcc-8 warning 2017-08-25 18:26:52 -04:00
lpfc_disc.h scsi: lpfc: Fix handling of FCP and NVME FC4 types in Pt2Pt topology 2017-08-24 22:29:37 -04:00
lpfc_els.c scsi: lpfc: Fix crash receiving ELS while detaching driver 2017-11-30 08:40:50 +00:00
lpfc_hbadisc.c scsi: lpfc: PLOGI failures during NPIV testing 2017-12-25 14:26:29 +01:00
lpfc_hw.h scsi: lpfc: Add Buffer to Buffer credit recovery support 2017-08-24 22:29:43 -04:00
lpfc_hw4.h scsi: lpfc: Fix secure firmware updates 2017-12-25 14:26:28 +01:00
lpfc_ids.h scsi: lpfc: Update copyrights 2017-02-22 18:41:44 -05:00
lpfc_init.c scsi: lpfc: Fix crash after bad bar setup on driver attachment 2018-02-16 20:23:11 +01:00
lpfc_logmsg.h scsi: lpfc: Update copyrights 2017-02-22 18:41:44 -05:00
lpfc_mbox.c scsi: lpfc: Add Buffer to Buffer credit recovery support 2017-08-24 22:29:43 -04:00
lpfc_mem.c scsi: lpfc: Replace PCI pool old API 2017-08-07 14:04:01 -04:00
lpfc_nl.h scsi: lpfc: Update copyrights 2017-02-22 18:41:44 -05:00
lpfc_nportdisc.c scsi: lpfc: Fix crash receiving ELS while detaching driver 2017-11-30 08:40:50 +00:00
lpfc_nvme.c lpfc: remove use of FC-specific error codes 2017-09-25 08:56:05 -06:00
lpfc_nvme.h scsi: lpfc: Fix transition nvme-i rport handling to nport only. 2017-06-12 21:37:30 -04:00
lpfc_nvmet.c scsi: lpfc: Fix warning messages when NVME_TARGET_FC not defined 2017-12-25 14:26:29 +01:00
lpfc_nvmet.h SCSI misc on 20170907 2017-09-07 21:11:05 -07:00
lpfc_scsi.c scsi: lpfc: Replace PCI pool old API 2017-08-07 14:04:01 -04:00
lpfc_scsi.h scsi: lpfc: Update copyrights 2017-02-22 18:41:44 -05:00
lpfc_sli.c scsi: lpfc: Fix FCP hba_wqidx assignment 2017-11-30 08:40:50 +00:00
lpfc_sli.h scsi: lpfc: Add auto EQ delay logic 2017-06-12 21:37:31 -04:00
lpfc_sli4.h scsi: lpfc: Add Buffer to Buffer credit recovery support 2017-08-24 22:29:43 -04:00
lpfc_version.h scsi: lpfc: lpfc version bump 11.4.0.3 2017-08-24 22:29:44 -04:00
lpfc_vport.c Fix crash after issuing lip reset 2017-04-24 09:25:49 +02:00
lpfc_vport.h scsi: lpfc: Update copyrights 2017-02-22 18:41:44 -05:00
Makefile scsi: lpfc: Update copyrights 2017-02-22 18:41:44 -05:00