Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756948Ab1EaORF (ORCPT ); Tue, 31 May 2011 10:17:05 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:44681 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756869Ab1EaOQy (ORCPT ); Tue, 31 May 2011 10:16:54 -0400 From: Julia Lawall To: Brian King Cc: kernel-janitors@vger.kernel.org, "James E.J. Bottomley" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] drivers/scsi/ipr.c: reorder error handling code to include iounmap Date: Tue, 31 May 2011 16:16:49 +0200 Message-Id: <1306851409-14963-1-git-send-email-julia@diku.dk> X-Mailer: git-send-email 1.7.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2302 Lines: 88 From: Julia Lawall 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/) // @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 ) // Signed-off-by: Julia Lawall --- drivers/scsi/ipr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 888086c..8d63630 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -8778,14 +8778,14 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev, if (rc != PCIBIOS_SUCCESSFUL) { dev_err(&pdev->dev, "Failed to save PCI config space\n"); rc = -EIO; - goto cleanup_nomem; + goto out_msi_disable; } if ((rc = ipr_save_pcix_cmd_reg(ioa_cfg))) - goto cleanup_nomem; + goto out_msi_disable; if ((rc = ipr_set_pcix_cmd_reg(ioa_cfg))) - goto cleanup_nomem; + goto out_msi_disable; if (ioa_cfg->sis64) ioa_cfg->cfg_table_size = (sizeof(struct ipr_config_table_hdr64) @@ -8800,7 +8800,7 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev, if (rc < 0) { dev_err(&pdev->dev, "Couldn't allocate enough memory for device driver!\n"); - goto cleanup_nomem; + goto out_msi_disable; } /* @@ -8845,10 +8845,10 @@ out: cleanup_nolog: ipr_free_mem(ioa_cfg); -cleanup_nomem: - iounmap(ipr_regs); out_msi_disable: pci_disable_msi(pdev); +cleanup_nomem: + iounmap(ipr_regs); out_release_regions: pci_release_regions(pdev); out_scsi_host_put: -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/