[SCSI] SCSI aic94xx: handle sysfs errors

Handle and unwind from errors returned by driver model functions.

Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by Jeff Garzik and committed by James Bottomley bb076620 13026a6b

+33 -8
+33 -8
drivers/scsi/aic94xx/aic94xx_init.c
··· 310 310 } 311 311 static DEVICE_ATTR(pcba_sn, S_IRUGO, asd_show_dev_pcba_sn, NULL); 312 312 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) 314 314 { 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; 318 336 } 319 337 320 338 static void asd_remove_dev_attrs(struct asd_ha_struct *asd_ha) ··· 664 646 } 665 647 ASD_DPRINTK("escbs posted\n"); 666 648 667 - asd_create_dev_attrs(asd_ha); 649 + err = asd_create_dev_attrs(asd_ha); 650 + if (err) 651 + goto Err_dev_attrs; 668 652 669 653 err = asd_register_sas_ha(asd_ha); 670 654 if (err) ··· 689 669 asd_unregister_sas_ha(asd_ha); 690 670 Err_reg_sas: 691 671 asd_remove_dev_attrs(asd_ha); 672 + Err_dev_attrs: 692 673 Err_escbs: 693 674 asd_disable_ints(asd_ha); 694 675 free_irq(dev->irq, asd_ha); ··· 776 755 } 777 756 static DRIVER_ATTR(version, S_IRUGO, asd_version_show, NULL); 778 757 779 - static void asd_create_driver_attrs(struct device_driver *driver) 758 + static int asd_create_driver_attrs(struct device_driver *driver) 780 759 { 781 - driver_create_file(driver, &driver_attr_version); 760 + return driver_create_file(driver, &driver_attr_version); 782 761 } 783 762 784 763 static void asd_remove_driver_attrs(struct device_driver *driver) ··· 856 835 if (err) 857 836 goto out_release_transport; 858 837 859 - asd_create_driver_attrs(&aic94xx_pci_driver.driver); 838 + err = asd_create_driver_attrs(&aic94xx_pci_driver.driver); 839 + if (err) 840 + goto out_unregister_pcidrv; 860 841 861 842 return err; 862 843 844 + out_unregister_pcidrv: 845 + pci_unregister_driver(&aic94xx_pci_driver); 863 846 out_release_transport: 864 847 sas_release_transport(aic94xx_transport_template); 865 848 out_destroy_caches: