scsi_register cleanup
Subsystems (3)
PATCH 1/1 scsi_register cleanup
Hi,
this is part of the Kernel Janitor Project. As seen on the TODO list, I checked every call to the scsi_register() function and added a check for the return code where there wasn't any. Using cscope I checked every file that had a function calling scsi_register(), so I'm pretty much sure, that this is cleaned now. Patch against 2.5.3-dj4. Please review and apply if correct and appropriate.
Regards,
Todor
drivers/acorn/scsi/acornscsi.c +35 -6
@@ -2898,6 +2898,9 @@ecard_claim (ecs[count]);/* Must claim here - card produces irq on reset */ instance =scsi_register (tpnt,sizeof (AS_Host)); +if ( !instance ) +return count; + host = (AS_Host *)instance->hostdata; instance->io_port =ecard_address (ecs[count],ECARD_MEMC ,0 );
@@ -2915,13 +2918,26 @@ ecs[count]->irqaddr = (char *)ioaddr (host->card.io_intr); ecs[count]->irqmask =0x0a ; -request_region (instance->io_port +0x800 ,2 ,"acornscsi(sbic)" ); -request_region (host->card.io_intr,1 ,"acornscsi(intr)" ); -request_region (host->card.io_page,1 ,"acornscsi(page)" ); +if ( !(request_region (instance->io_port +0x800 ,2 ,"acornscsi(sbic)" )) ) + goto unregister_scsi; + +if ( !(request_region (host->card.io_intr,1 ,"acornscsi(intr)" )) ) + goto release_first; + +if ( !(request_region (host->card.io_page,1 ,"acornscsi(page)" )) ) + goto release_second; +#ifdef USE_DMAC -request_region (host->dma.io_port,256 ,"acornscsi(dmac)" ); +if ( !(request_region (host->dma.io_port,256 ,"acornscsi(dmac)" )) ) + goto release_third; +#endif + + if( !(request_region(instance->io_port, 2048, "acornscsi(ram)")) ) +#ifdef USE_DMAC + goto release_fourth; +#else + goto release_third;#endif -request_region (instance->io_port,2048 ,"acornscsi(ram)" );if (request_irq (host->scsi.irq, acornscsi_intr,SA_INTERRUPT ,"acornscsi" , host)) { printk(KERN_CRIT "scsi%d: IRQ%d not free, interrupts disabled\n",
@@ -2933,7 +2949,20 @@ ++count; } -return count; + +out:return count; + +release_fourth: +release_region ( host->dma.io_port,256 ); +release_third: +release_region ( host->card.io_page,1 ); +release_second: +release_region ( host->card.io_intr,1 ); +release_first: +release_region ( instance->io_port +0x800 ,2 ); +unregister_scsi: +scsi_unregister ( instance ); + goto out; }/*
drivers/acorn/scsi/cumana_1.c +10 -2
@@ -141,6 +141,9 @@break ; instance =scsi_register (tpnt,sizeof (struct NCR5380_hostdata )); +if ( !instance ) + goto out; + instance->io_port =CUMANA_ADDRESS (ecs[count]); instance->irq =CUMANA_IRQ (ecs[count]);
@@ -148,7 +151,8 @@ecard_claim (ecs[count]); instance->n_io_port =255 ; -request_region (instance->io_port, instance->n_io_port,"CumanaSCSI-1" ); +if ( !(request_region (instance->io_port, instance->n_io_port,"CumanaSCSI-1" )) ) + goto unregister_scsi; ((struct NCR5380_hostdata *)instance->hostdata)->ctrl =0 ;outb (0x00 , instance->io_port -577 );
@@ -178,7 +182,11 @@ ++count; } -return count; + +out:return count; +unregister_scsi: +scsi_unregister ( instance ); + goto out; }int cumanascsi_release (struct Scsi_Host *shpnt)
drivers/acorn/scsi/ecoscsi.c +17 -14
@@ -104,28 +104,25 @@ tpnt->proc_name ="ecoscsi" ; instance =scsi_register (tpnt,sizeof (struct NCR5380_hostdata )); +if ( !instance ) +return 0 ; + instance->io_port =0x80ce8000 ; instance->n_io_port =144 ; instance->irq =IRQ_NONE ; -if (check_region (instance->io_port, instance->n_io_port)) { -scsi_unregister (instance); -return 0 ; - } +if ( !(request_region (instance->io_port, instance->n_io_port,"ecoscsi" )) ) + goto unregister_scsi;ecoscsi_write (instance,MODE_REG ,0x20 );/* Is it really SCSI? */ -if (ecoscsi_read (instance,MODE_REG ) !=0x20 ) {/* Write to a reg. */ -scsi_unregister (instance); -return 0 ;/* and try to read */ - } +if (ecoscsi_read (instance,MODE_REG ) !=0x20 )/* Write to a reg. */ + goto release_reg;/* and try to read */ +ecoscsi_write ( instance,MODE_REG ,0x00 );/* it back. */ -if (ecoscsi_read (instance,MODE_REG ) !=0x00 ) { -scsi_unregister (instance); -return 0 ; - } +if (ecoscsi_read (instance,MODE_REG ) !=0x00 ) + goto release_reg;NCR5380_init (instance,0 ); -request_region (instance->io_port, instance->n_io_port,"ecoscsi" );if (instance->irq !=IRQ_NONE )if (request_irq (instance->irq, do_ecoscsi_intr,SA_INTERRUPT ,"ecoscsi" ,NULL )) {
@@ -149,7 +146,13 @@printk ("\nscsi%d:" , instance->host_no);NCR5380_print_options (instance);printk ("\n" ); -return 1 ; + +return 1 ; +release_reg: +release_region ( instance->io_port, instance->n_io_port ); +unregister_scsi: +scsi_unregister ( instance ); +return 0 ; }int ecoscsi_release (struct Scsi_Host *shpnt)
drivers/acorn/scsi/oak.c +9 -1
@@ -127,6 +127,9 @@break ; instance =scsi_register (tpnt,sizeof (struct NCR5380_hostdata )); +if ( !instance ) + goto out; + instance->io_port =OAK_ADDRESS (ecs[count]); instance->irq =OAK_IRQ (ecs[count]);
@@ -134,7 +137,8 @@ecard_claim (ecs[count]); instance->n_io_port =255 ; -request_region (instance->io_port, instance->n_io_port,"Oak SCSI" ); +if ( !(request_region (instance->io_port, instance->n_io_port,"Oak SCSI" )) ) + goto unregister_scsi:if (instance->irq !=IRQ_NONE )if (request_irq (instance->irq, do_oakscsi_intr,SA_INTERRUPT ,"Oak SCSI" ,NULL )) {
@@ -165,7 +169,11 @@if (count ==0 )printk ("No oak scsi devices found\n" );#endif + +out:return count; +unregister_scsi: +scsi_unregister ( instance ); }int oakscsi_release (struct Scsi_Host *shpnt)
drivers/scsi/aacraid/linit.c +2 -0
@@ -189,6 +189,8 @@* specific information. */ host_ptr =scsi_register ( template,sizeof (struct aac_dev ) ); +if ( !host_ptr ) +continue ;/* * These three parameters can be used to allow for wide SCSI * and for host adapters that support multiple buses.
drivers/scsi/gdth.c +237 -231
548 lines not on this page · raw message
drivers/scsi/pci2220i.c +3 -0
@@ -2643,6 +2643,9 @@while ( (pcidev =pci_find_device (VENDOR_PSI ,DEVICE_BIGD_1 , pcidev)) !=NULL ) { pshost =scsi_register (tpnt,sizeof (ADAPTER2220I )); +if ( pshost ==NULL ) +continue ; + padapter =HOSTDATA (pshost);if (GetRegs (pshost, TRUE, pcidev) )
drivers/scsi/pcmcia/nsp_cs.c +9 -1
@@ -1185,8 +1185,16 @@DEBUG (0 , __FUNCTION__" this_id=%d\n" , sht->this_id); -request_region (data->BaseAddress, data->NumAddress,"nsp_cs" ); +if ( !(request_region (data->BaseAddress, data->NumAddress,"nsp_cs" ) ) ) +return 0 ; + host =scsi_register (sht,0 ); + +if ( !host ) { +release_region ( data->BaseAddress, data->NumAddress ); +return 0 ; + } + host->io_port = data->BaseAddress; host->unique_id = data->BaseAddress; host->n_io_port = data->NumAddress;