[PATCH 2/2] drivers, pcmcia: check return code of request_irq and request_region in drivers/pcmcia/m32r_pcc.c

Qiaowei Ren qiaowei.ren at intel.com
Wed Jan 22 14:03:24 EST 2014


The patch below adds a check to drivers/pcmcia/m32r_pcc.c for the
return code of request_irq and request_region.

Signed-off-by: Qiaowei Ren <qiaowei.ren at intel.com>
---
 drivers/pcmcia/m32r_pcc.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c
index 2965141..5c07fd1 100644
--- a/drivers/pcmcia/m32r_pcc.c
+++ b/drivers/pcmcia/m32r_pcc.c
@@ -315,7 +315,11 @@ static void add_pcc_socket(ulong base, int irq, ulong mapaddr,
 
 	/* add pcc */
 	if (t->base > 0) {
-		request_region(t->base, 0x20, "m32r-pcc");
+		if (!request_region(t->base, 0x20, "m32r-pcc")) {
+			printk(KERN_ERR "m32r_pcc: request_region 0x%x failed.\n",
+					t->base);
+			return;
+		}
 	}
 
 	printk(KERN_INFO "  %s ", pcc[pcc_sockets].name);
@@ -328,10 +332,15 @@ static void add_pcc_socket(ulong base, int irq, ulong mapaddr,
 	t->socket.irq_mask = 0;
 	t->socket.pci_irq = 2 + pcc_sockets; /* XXX */
 
-	request_irq(irq, pcc_interrupt, 0, "m32r-pcc", pcc_interrupt);
+	if (request_irq(irq, pcc_interrupt, 0, "m32r-pcc", pcc_interrupt) != 0) {
+		printk(KERN_ERR "m32r_pcc: request_irq %d failed.\n", irq);
+		goto out;
+	}
 
 	pcc_sockets++;
 
+out:
+	release_region(t->base, 0x20);
 	return;
 }
 
-- 
1.7.1




More information about the linux-pcmcia mailing list