Commit f170c684b55cb8d3bab55b1fb8fa812778d551f2
Committed by
James Bottomley
1 parent
b5b515445f
Exists in
master
and in
4 other branches
[SCSI] ipr: reorder error handling code to include iounmap
The out_msi_disable label should be before cleanup_nomem to additionally benefit from the call to iounmap. Subsequent gotos are adjusted to go to out_msi_disable instead of cleanup_nomem, which now follows it. This is safe because pci_disable_msi does nothing if pci_enable_msi was not called. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @r@ expression e1,e2; statement S; @@ e1 = pci_ioremap_bar(...); ... when != e1 = e2 when != iounmap(e1) when any ( if (<+...e1...+>) S | if(...) { ... return 0; } | if (...) { ... when != iounmap(e1) when != if (...) { ... iounmap(e1) ... } * return ...; } else S ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Acked-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Showing 1 changed file with 6 additions and 6 deletions Side-by-side Diff
drivers/scsi/ipr.c
... | ... | @@ -8778,14 +8778,14 @@ |
8778 | 8778 | if (rc != PCIBIOS_SUCCESSFUL) { |
8779 | 8779 | dev_err(&pdev->dev, "Failed to save PCI config space\n"); |
8780 | 8780 | rc = -EIO; |
8781 | - goto cleanup_nomem; | |
8781 | + goto out_msi_disable; | |
8782 | 8782 | } |
8783 | 8783 | |
8784 | 8784 | if ((rc = ipr_save_pcix_cmd_reg(ioa_cfg))) |
8785 | - goto cleanup_nomem; | |
8785 | + goto out_msi_disable; | |
8786 | 8786 | |
8787 | 8787 | if ((rc = ipr_set_pcix_cmd_reg(ioa_cfg))) |
8788 | - goto cleanup_nomem; | |
8788 | + goto out_msi_disable; | |
8789 | 8789 | |
8790 | 8790 | if (ioa_cfg->sis64) |
8791 | 8791 | ioa_cfg->cfg_table_size = (sizeof(struct ipr_config_table_hdr64) |
... | ... | @@ -8800,7 +8800,7 @@ |
8800 | 8800 | if (rc < 0) { |
8801 | 8801 | dev_err(&pdev->dev, |
8802 | 8802 | "Couldn't allocate enough memory for device driver!\n"); |
8803 | - goto cleanup_nomem; | |
8803 | + goto out_msi_disable; | |
8804 | 8804 | } |
8805 | 8805 | |
8806 | 8806 | /* |
8807 | 8807 | |
... | ... | @@ -8845,10 +8845,10 @@ |
8845 | 8845 | |
8846 | 8846 | cleanup_nolog: |
8847 | 8847 | ipr_free_mem(ioa_cfg); |
8848 | -cleanup_nomem: | |
8849 | - iounmap(ipr_regs); | |
8850 | 8848 | out_msi_disable: |
8851 | 8849 | pci_disable_msi(pdev); |
8850 | +cleanup_nomem: | |
8851 | + iounmap(ipr_regs); | |
8852 | 8852 | out_release_regions: |
8853 | 8853 | pci_release_regions(pdev); |
8854 | 8854 | out_scsi_host_put: |