Skip to content

Commit bb07662

Browse files
Jeff GarzikJames Bottomley
authored andcommitted
[SCSI] SCSI aic94xx: handle sysfs errors
Handle and unwind from errors returned by driver model functions. Signed-off-by: Jeff Garzik <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent 13026a6 commit bb07662

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

drivers/scsi/aic94xx/aic94xx_init.c

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,29 @@ static ssize_t asd_show_dev_pcba_sn(struct device *dev,
310310
}
311311
static DEVICE_ATTR(pcba_sn, S_IRUGO, asd_show_dev_pcba_sn, NULL);
312312

313-
static void asd_create_dev_attrs(struct asd_ha_struct *asd_ha)
313+
static int asd_create_dev_attrs(struct asd_ha_struct *asd_ha)
314314
{
315-
device_create_file(&asd_ha->pcidev->dev, &dev_attr_revision);
316-
device_create_file(&asd_ha->pcidev->dev, &dev_attr_bios_build);
317-
device_create_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn);
315+
int err;
316+
317+
err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_revision);
318+
if (err)
319+
return err;
320+
321+
err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_bios_build);
322+
if (err)
323+
goto err_rev;
324+
325+
err = device_create_file(&asd_ha->pcidev->dev, &dev_attr_pcba_sn);
326+
if (err)
327+
goto err_biosb;
328+
329+
return 0;
330+
331+
err_biosb:
332+
device_remove_file(&asd_ha->pcidev->dev, &dev_attr_bios_build);
333+
err_rev:
334+
device_remove_file(&asd_ha->pcidev->dev, &dev_attr_revision);
335+
return err;
318336
}
319337

320338
static void asd_remove_dev_attrs(struct asd_ha_struct *asd_ha)
@@ -646,7 +664,9 @@ static int __devinit asd_pci_probe(struct pci_dev *dev,
646664
}
647665
ASD_DPRINTK("escbs posted\n");
648666

649-
asd_create_dev_attrs(asd_ha);
667+
err = asd_create_dev_attrs(asd_ha);
668+
if (err)
669+
goto Err_dev_attrs;
650670

651671
err = asd_register_sas_ha(asd_ha);
652672
if (err)
@@ -669,6 +689,7 @@ static int __devinit asd_pci_probe(struct pci_dev *dev,
669689
asd_unregister_sas_ha(asd_ha);
670690
Err_reg_sas:
671691
asd_remove_dev_attrs(asd_ha);
692+
Err_dev_attrs:
672693
Err_escbs:
673694
asd_disable_ints(asd_ha);
674695
free_irq(dev->irq, asd_ha);
@@ -755,9 +776,9 @@ static ssize_t asd_version_show(struct device_driver *driver, char *buf)
755776
}
756777
static DRIVER_ATTR(version, S_IRUGO, asd_version_show, NULL);
757778

758-
static void asd_create_driver_attrs(struct device_driver *driver)
779+
static int asd_create_driver_attrs(struct device_driver *driver)
759780
{
760-
driver_create_file(driver, &driver_attr_version);
781+
return driver_create_file(driver, &driver_attr_version);
761782
}
762783

763784
static void asd_remove_driver_attrs(struct device_driver *driver)
@@ -835,10 +856,14 @@ static int __init aic94xx_init(void)
835856
if (err)
836857
goto out_release_transport;
837858

838-
asd_create_driver_attrs(&aic94xx_pci_driver.driver);
859+
err = asd_create_driver_attrs(&aic94xx_pci_driver.driver);
860+
if (err)
861+
goto out_unregister_pcidrv;
839862

840863
return err;
841864

865+
out_unregister_pcidrv:
866+
pci_unregister_driver(&aic94xx_pci_driver);
842867
out_release_transport:
843868
sas_release_transport(aic94xx_transport_template);
844869
out_destroy_caches:

0 commit comments

Comments
 (0)