@@ -310,11 +310,29 @@ static ssize_t asd_show_dev_pcba_sn(struct device *dev,
310310}
311311static 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
320338static 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 );
670690Err_reg_sas :
671691 asd_remove_dev_attrs (asd_ha );
692+ Err_dev_attrs :
672693Err_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}
756777static 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
763784static 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