aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/shpchp_hpc.c
diff options
context:
space:
mode:
authorAmol Lad <amol@verismonetworks.com>2006-10-05 02:37:32 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-10-18 14:36:11 -0400
commit662a98fb8de5af4adb56e58f78753cdaa27b6459 (patch)
tree85f131f870e407b8cadb9364e582da3878e787bb /drivers/pci/hotplug/shpchp_hpc.c
parent6aa562c248e05db993e4a5f405f899c0cfabb7f2 (diff)
PCI hotplug: ioremap balanced with iounmap
1. ioremap must be balanced by an iounmap and failing to do so can result in a memory leak. 2. Handle return value correctly Tested (compilation only) with: - allmodconfig Signed-off-by: Amol Lad <amol@verismonetworks.com> Cc: Kristen Carlson Accardi <kristen.c.accardi@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/hotplug/shpchp_hpc.c')
-rw-r--r--drivers/pci/hotplug/shpchp_hpc.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
index bbe450f098e6..83a5226ba9ed 100644
--- a/drivers/pci/hotplug/shpchp_hpc.c
+++ b/drivers/pci/hotplug/shpchp_hpc.c
@@ -1118,7 +1118,7 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1118{ 1118{
1119 struct php_ctlr_state_s *php_ctlr, *p; 1119 struct php_ctlr_state_s *php_ctlr, *p;
1120 void *instance_id = ctrl; 1120 void *instance_id = ctrl;
1121 int rc, num_slots = 0; 1121 int rc = -1, num_slots = 0;
1122 u8 hp_slot; 1122 u8 hp_slot;
1123 u32 shpc_base_offset; 1123 u32 shpc_base_offset;
1124 u32 tempdword, slot_reg, slot_config; 1124 u32 tempdword, slot_reg, slot_config;
@@ -1184,11 +1184,15 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1184 info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor, 1184 info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor,
1185 pdev->subsystem_device); 1185 pdev->subsystem_device);
1186 1186
1187 if (pci_enable_device(pdev)) 1187 rc = pci_enable_device(pdev);
1188 if (rc) {
1189 err("%s: pci_enable_device failed\n", __FUNCTION__);
1188 goto abort_free_ctlr; 1190 goto abort_free_ctlr;
1191 }
1189 1192
1190 if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) { 1193 if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) {
1191 err("%s: cannot reserve MMIO region\n", __FUNCTION__); 1194 err("%s: cannot reserve MMIO region\n", __FUNCTION__);
1195 rc = -1;
1192 goto abort_free_ctlr; 1196 goto abort_free_ctlr;
1193 } 1197 }
1194 1198
@@ -1197,6 +1201,7 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1197 err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__, 1201 err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__,
1198 ctrl->mmio_size, ctrl->mmio_base); 1202 ctrl->mmio_size, ctrl->mmio_base);
1199 release_mem_region(ctrl->mmio_base, ctrl->mmio_size); 1203 release_mem_region(ctrl->mmio_base, ctrl->mmio_size);
1204 rc = -1;
1200 goto abort_free_ctlr; 1205 goto abort_free_ctlr;
1201 } 1206 }
1202 dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg); 1207 dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg);
@@ -1299,8 +1304,10 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1299 */ 1304 */
1300 if (atomic_add_return(1, &shpchp_num_controllers) == 1) { 1305 if (atomic_add_return(1, &shpchp_num_controllers) == 1) {
1301 shpchp_wq = create_singlethread_workqueue("shpchpd"); 1306 shpchp_wq = create_singlethread_workqueue("shpchpd");
1302 if (!shpchp_wq) 1307 if (!shpchp_wq) {
1303 return -ENOMEM; 1308 rc = -ENOMEM;
1309 goto abort_free_ctlr;
1310 }
1304 } 1311 }
1305 1312
1306 /* 1313 /*
@@ -1330,8 +1337,10 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1330 1337
1331 /* We end up here for the many possible ways to fail this API. */ 1338 /* We end up here for the many possible ways to fail this API. */
1332abort_free_ctlr: 1339abort_free_ctlr:
1340 if (php_ctlr->creg)
1341 iounmap(php_ctlr->creg);
1333 kfree(php_ctlr); 1342 kfree(php_ctlr);
1334abort: 1343abort:
1335 DBG_LEAVE_ROUTINE 1344 DBG_LEAVE_ROUTINE
1336 return -1; 1345 return rc;
1337} 1346}