All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] [PATCH] drivers/char/mxser.c: check request_region()
@ 2006-07-03 22:52 Richard
  2006-07-03 23:12 ` Randy.Dunlap
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Richard @ 2006-07-03 22:52 UTC (permalink / raw)
  To: kernel-janitors

Check return value of request_region and release already requested region if the
second fails

Signed-of-by: Richard van Berkum

--- janitor-2.6/drivers/char/mxser.c	2006-07-01 11:54:45.895077096 +0200
+++ mytree/drivers/char/mxser.c	2006-07-04 02:52:17.965040344 +0200
@@ -642,16 +642,24 @@ static int mxser_get_PCI_conf(int busnum
 	hwconf->board_type = board_type;
 	hwconf->ports = mxser_numports[board_type - 1];
 	ioaddress = pci_resource_start(pdev, 2);
-	request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2),
-			"mxser(IO)");
+	if(!(request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2),
+			"mxser(IO)"))){
+		printk(KERN_ERR "mxser: I/O ports already in use\n");
+		return (-EIO);
+	}
+

 	for (i = 0; i < hwconf->ports; i++)
 		hwconf->ioaddr[i] = ioaddress + 8 * i;

 	/* vector */
 	ioaddress = pci_resource_start(pdev, 3);
-	request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3),
-			"mxser(vector)");
+	if(!(request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3),
+			"mxser(vector)"))){
+		printk(KERN_ERR "mxser: I/O ports already in use\n");
+		goto out;
+	}
+	
 	hwconf->vector = ioaddress;

 	/* irq */
@@ -691,6 +699,10 @@ static int mxser_get_PCI_conf(int busnum
 		hwconf->baud_base[i] = 921600;
 	}
 	return 0;
+out:
+	release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2));
+	return (-EIO);
+
 }
 #endif

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-07-04  0:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-03 22:52 [KJ] [PATCH] drivers/char/mxser.c: check request_region() Richard
2006-07-03 23:12 ` Randy.Dunlap
2006-07-03 23:30 ` Richard
2006-07-04  0:01 ` Richard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.