Hi,
Please take a look and consider applying. This driver also needs conversion
to the new PCI API.
- Arnaldo
--- linux-2.4.0-test7-pre3/drivers/char/ip2main.c Fri Jul 28 06:34:41 2000
+++ linux-2.4.0-test7-pre3.acme/drivers/char/ip2main.c Mon Aug 14 13:02:47 2000
@@ -8,6 +8,11 @@
* serial I/O controllers.
*
* DESCRIPTION: Mainline code for the device driver
+*
+* Changes:
+* Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 08/14/2000
+* - check resource allocation in ip2_init_board, fixing leakage on failure
+* - driver proc entries should be in /proc/driver
*
*******************************************************************************/
// ToDo:
@@ -541,7 +546,7 @@
{
printk(KERN_ERR "IP2: failed to unregister IPL driver (%d)\n", err);
}
- remove_proc_entry("ip2mem", &proc_root);
+ remove_proc_entry("ip2mem", proc_root_driver);
// free memory
for (i = 0; i < IP2_MAX_BOARDS; i++) {
@@ -849,7 +854,7 @@
printk(KERN_ERR "IP2: failed to register IPL device (%d)\n", err );
} else
/* Register the read_procmem thing */
- if (!create_proc_info_entry("ip2mem",0,&proc_root,ip2_read_procmem)) {
+ if (!create_proc_info_entry("ip2mem",0,proc_root_driver,ip2_read_procmem)) {
printk(KERN_ERR "IP2: failed to register read_procmem\n");
} else {
@@ -961,28 +966,23 @@
static void __init
ip2_init_board( int boardnum )
{
- int i,rc;
- int nports = 0, nboxes = 0;
+ int i, nports = 0, nboxes = 0;
i2ChanStrPtr pCh;
i2eBordStrPtr pB = i2BoardPtrTable[boardnum];
if ( !iiInitialize ( pB ) ) {
printk ( KERN_ERR "IP2: Failed to initialize board at 0x%x, error %d\n",
pB->i2eBase, pB->i2eError );
- kfree ( pB );
- i2BoardPtrTable[boardnum] = NULL;
- return;
+ goto cleanup_pB;
}
printk(KERN_INFO "Board %d: addr=0x%x irq=%d ", boardnum + 1,
ip2config.addr[boardnum], ip2config.irq[boardnum] );
- if (0 != ( rc = check_region( ip2config.addr[boardnum], 8))) {
- i2BoardPtrTable[boardnum] = NULL;
- printk(KERN_ERR "bad addr=0x%x rc = %d\n",
- ip2config.addr[boardnum], rc );
- return;
+ if (!request_region(ip2config.addr[boardnum], 8, pcName)) {
+ printk(KERN_ERR "bad addr=0x%x\n",
+ ip2config.addr[boardnum]);
+ goto cleanup_pB;
}
- request_region( ip2config.addr[boardnum], 8, pcName );
if ( iiDownloadAll ( pB, (loadHdrStrPtr)Fip_firmware, 1, Fip_firmware_size )
!= II_DOWN_GOOD ) {
@@ -1036,6 +1036,13 @@
}
DevTableMem[boardnum] = pCh =
kmalloc( sizeof(i2ChanStr) * nports, GFP_KERNEL );
+
+ if (!pCh) {
+ printk (KERN_ERR "IP2: out of memory for board at 0x%x\n",
+ pB->i2eBase);
+ goto cleanup_region;
+ }
+
if ( !i2InitChannels( pB, nports, pCh ) ) {
printk(KERN_ERR "i2InitChannels failed: %d\n",pB->i2eError);
}
@@ -1055,10 +1062,16 @@
nboxes, nports, pB->i2eDataWidth16 ? 16 : 8 );
}
goto ex_exit;
- break;
}
DevTableMem[boardnum] = pCh =
kmalloc ( sizeof (i2ChanStr) * nports, GFP_KERNEL );
+
+ if (!pCh) {
+ printk (KERN_ERR "IP2: out of memory for board at 0x%x\n",
+ pB->i2eBase);
+ goto cleanup_region;
+ }
+
pB->i2eChannelPtr = pCh;
pB->i2eChannelCnt = nports;
i2InitChannels ( pB, pB->i2eChannelCnt, pCh );
@@ -1071,6 +1084,11 @@
}
ex_exit:
printk ( KERN_INFO "\n" );
+ return;
+
+cleanup_region: release_region(ip2config.addr[boardnum], 8);
+cleanup_pB: kfree (pB);
+ i2BoardPtrTable[boardnum] = NULL;
}
/******************************************************************************/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Tue Aug 15 2000 - 21:00:33 EST