diff mbox

[v2,3/4] hpet: clean up io mapping when hpet_alloc() fails

Message ID 20100318175940.15143.53027.stgit@bob.kio (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Bjorn Helgaas March 18, 2010, 5:59 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index d132fef..8961985 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -904,7 +904,7 @@  static int hpet_pnp_add(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
 {
 	struct hpet_data data;
 	struct resource *mem, *irq;
-	int i;
+	int i, ret;
 
 	memset(&data, 0, sizeof(data));
 
@@ -924,7 +924,11 @@  static int hpet_pnp_add(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
 	data.hd_phys_address = mem->start;
 	data.hd_address = ioremap(mem->start, resource_size(mem));
 
-	return hpet_alloc(&data);
+	ret = hpet_alloc(&data);
+	if (ret)
+		iounmap(data.hd_address);
+
+	return ret;
 }
 
 static void hpet_pnp_remove(struct pnp_dev *dev)