simscsi: Free scsi host on error
Subsystems (4)
PATCH 1/1 simscsi: Free scsi host on error
If scsi_add_host returned an error, the host would never be freed. We need to call scsi_host_put() if an error happens.
--- arch/ia64/hp/sim/simscsi.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
arch/ia64/hp/sim/simscsi.c +7 -2
@@ -373,8 +373,13 @@ simscsi_init(void)return -ENOMEM ; error =scsi_add_host (host,NULL ); -if (!error) -scsi_scan_host (host); +if (error) + goto free_host; +scsi_scan_host (host); +return 0 ; + + free_host: +scsi_host_put (host);return error; }
Signature · 1 line
1.5.2.4
PATCH 1/1 aic94xx: Free scsi host on error
If an error occurred during initialisation, we would sometimes fail to call scsi_host_put() and thus end up with a leaked scsi_host. It was also possible to miss calling scsi_remove_host().
--- drivers/scsi/aic94xx/aic94xx_init.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-)
drivers/scsi/aic94xx/aic94xx_init.c +9 -8
@@ -583,7 +583,7 @@ static int __devinit asd_pci_probe(struct pci_dev *dev, asd_ha =kzalloc (sizeof (*asd_ha),GFP_KERNEL );if (!asd_ha) {asd_printk ("out of memory\n" ); - goto Err; + goto Err_put; } asd_ha->pcidev = dev; asd_ha->sas_ha.dev = &asd_ha->pcidev->dev;
@@ -600,14 +600,12 @@ static int __devinit asd_pci_probe(struct pci_dev *dev, shost->max_cmd_len =16 ; err =scsi_add_host (shost, &dev->dev); -if (err) { -scsi_host_put (shost); +if (err) goto Err_free; - } err = asd_dev->setup (asd_ha);if (err) - goto Err_free; + goto Err_remove; err = -ENODEV ; if (!pci_set_dma_mask(dev, DMA_64BIT_MASK)
@@ -618,14 +616,14 @@ static int __devinit asd_pci_probe(struct pci_dev *dev, ; else {asd_printk ("no suitable DMA mask for %s\n" ,pci_name (dev)); - goto Err_free; + goto Err_remove; }pci_set_drvdata (dev, asd_ha); err =asd_map_ha (asd_ha);if (err) - goto Err_free; + goto Err_remove; err =asd_create_ha_caches (asd_ha);if (err)
@@ -692,9 +690,12 @@ Err_free_cache:asd_destroy_ha_caches (asd_ha); Err_unmap:asd_unmap_ha (asd_ha); +Err_remove: +scsi_remove_host (shost); Err_free:kfree (asd_ha); -scsi_remove_host (shost); +Err_put: +scsi_host_put (shost); Err:pci_disable_device (dev);return err;
Signature · 1 line
1.5.2.4
PATCH 1/1 ncr53c8xx: Call scsi_host_put in release
Since ncr53c8xx_attach() calls scsi_host_put(), make ncr53c8xx_release() call scsi_host_put() too, for symmetry. Both callers already expect it to put the host for them, so that works out nicely. While the zalon driver does 'use' the host pointer afterwards, it only compares it for equality and doesn't dereference it, so that's safe.
While I'm at it, get rid of pointless checks for NULL, use shost_priv() and change ncr53c8xx_release to return void.
--- drivers/scsi/ncr53c8xx.c | 11 ++++------- drivers/scsi/ncr53c8xx.h | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-)
drivers/scsi/ncr53c8xx.c +4 -7
@@ -8528,18 +8528,15 @@ struct Scsi_Host * __init ncr_attach(struct scsi_host_template *tpnt, } -int ncr53c8xx_release (struct Scsi_Host *host) +void ncr53c8xx_release (struct Scsi_Host *host) { -struct host_data *host_data; +struct host_data *host_data =shost_priv (host);#ifdef DEBUG_NCR53C8XX printk ("ncr53c8xx: release\n" );#endif -if (!host) -return 1 ; - host_data = (struct host_data *)host->hostdata; -if (host_data && host_data->ncb) +if (host_data->ncb)ncr_detach (host_data->ncb); -return 1 ; +scsi_host_put (host); }static void ncr53c8xx_set_period (struct scsi_target *starget,int period)
drivers/scsi/ncr53c8xx.h +1 -1
@@ -1321,7 +1321,7 @@ struct ncr_device { };extern struct Scsi_Host *ncr_attach (struct scsi_host_template *tpnt,int unit,struct ncr_device *device); -extern int ncr53c8xx_release (struct Scsi_Host *host); +extern void ncr53c8xx_release (struct Scsi_Host *host);irqreturn_t ncr53c8xx_intr (int irq,void *dev_id);extern int ncr53c8xx_init (void );extern void ncr53c8xx_exit (void );
Signature · 1 line
1.5.2.4
PATCH 1/1 aha152x: Close narrow race in release
We were releasing the IRQ before removing the host, so commands could still be coming in which would never be seen by the interrupt handler. Just remove the host before releasing the IRQ to close this race.
--- drivers/scsi/aha152x.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/aha152x.c +2 -2
@@ -907,9 +907,10 @@ out_host_put:void aha152x_release (struct Scsi_Host *shpnt) { -if (!shpnt) +if (!shpnt)return ; +scsi_remove_host (shpnt);if (shpnt->irq)free_irq (shpnt->irq, shpnt);
@@ -923,7 +924,6 @@ void aha152x_release(struct Scsi_Host *shpnt)pnp_device_detach (HOSTDATA (shpnt)->pnpdev);#endif -scsi_remove_host (shpnt);list_del (&HOSTDATA (shpnt)->host_list);scsi_host_put (shpnt); }
Signature · 1 line
1.5.2.4
PATCH 1/1 ibmmca: Stop leaking scsi_hosts on exit
There was a missing call to scsi_host_put() causing us to leak a scsi host every time this module was unloaded.
--- drivers/scsi/ibmmca.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/scsi/ibmmca.c +1 -0
@@ -1693,6 +1693,7 @@ static int __devexit ibmmca_remove(struct device *dev)scsi_remove_host (shpnt);release_region (shpnt->io_port, shpnt->n_io_port);free_irq (shpnt->irq, dev); +scsi_host_put (shpnt);return 0 ; }
Signature · 1 line
1.5.2.4
PATCH 1/1 qlogicfas: Close narrow race in release
We were releasing the IRQ before removing the host, so commands could still be coming in which would never be seen by the interrupt handler. Just remove the host before releasing the IRQ to close this race.
--- drivers/scsi/qlogicfas.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/qlogicfas.c +1 -1
@@ -166,6 +166,7 @@ static int qlogicfas_release(struct Scsi_Host *shost) {struct qlogicfas408_priv *priv =get_priv_by_host (shost); +scsi_remove_host (shost);if (shost->irq) {qlogicfas408_disable_ints (priv);free_irq (shost->irq, shost);
@@ -174,7 +175,6 @@ static int qlogicfas_release(struct Scsi_Host *shost)free_dma (shost->dma_channel);if (shost->io_port && shost->n_io_port)release_region (shost->io_port, shost->n_io_port); -scsi_remove_host (shost);scsi_host_put (shost);return 0 ;
Signature · 1 line
1.5.2.4
PATCH 1/1 ips: Close narrow race in release
We were releasing the IRQ before removing the host, so commands could still be coming in which would never be seen by the interrupt handler. Just remove the host before releasing the IRQ to close this race.
--- drivers/scsi/ips.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/scsi/ips.c +2 -1
@@ -656,6 +656,8 @@ ips_release(struct Scsi_Host *sh)METHOD_TRACE ("ips_release" ,1 ); +scsi_remove_host (sh); +for (i =0 ; i <IPS_MAX_ADAPTERS && ips_sh[i] != sh; i++) ;if (i ==IPS_MAX_ADAPTERS ) {
@@ -707,7 +709,6 @@ ips_release(struct Scsi_Host *sh)/* free IRQ */ free_irq (ha->irq, ha); -scsi_remove_host (sh);scsi_host_put (sh); ips_released_controllers++;
Signature · 1 line
1.5.2.4
PATCH 1/1 ide-scsi: Close narrow race in release
We were releasing the block devices before removing the host, so commands could still be coming in which would cause a panic. Just remove the host before releasing the block devices to close this race.
--- drivers/scsi/ide-scsi.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/ide-scsi.c +1 -1
@@ -758,6 +758,7 @@ static void ide_scsi_remove(ide_drive_t *drive)struct ide_scsi_obj *scsi =scsihost_to_idescsi (scsihost);struct gendisk *g = scsi->disk; +scsi_remove_host (scsihost);ide_proc_unregister_driver (drive, scsi->driver);ide_unregister_region (g);
@@ -766,7 +767,6 @@ static void ide_scsi_remove(ide_drive_t *drive) g->private_data =NULL ;put_disk (g); -scsi_remove_host (scsihost);ide_scsi_put (scsi); }
Signature · 1 line
1.5.2.4