diff options
author | Jeff Garzik <jeff@garzik.org> | 2006-10-04 06:34:03 -0400 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-10-04 13:26:25 -0500 |
commit | 83aabc1be551dd1f07266c125ff48ec62a2ce515 (patch) | |
tree | 6a9add23d4f6d04d86dc33002e2089499f6e83d6 /drivers/scsi/megaraid/megaraid_sas.c | |
parent | bb0766204c81d6bd01532476aec4e512c960fb4d (diff) |
[SCSI] SCSI megaraid_sas: handle thrown errors
- handle clear_user() error
- handle and properly unwind from sysfs errors thrown during mod init
- adjust order of calls in megasas_exit() to precisely match
registration order in megasas_init()
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Updated for extra attribute and
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/megaraid/megaraid_sas.c')
-rw-r--r-- | drivers/scsi/megaraid/megaraid_sas.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c index e21f638c00a..977b6e8d852 100644 --- a/drivers/scsi/megaraid/megaraid_sas.c +++ b/drivers/scsi/megaraid/megaraid_sas.c @@ -2864,7 +2864,8 @@ static int megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg) int i; int error = 0; - clear_user(ioc, sizeof(*ioc)); + if (clear_user(ioc, sizeof(*ioc))) + return -EFAULT; if (copy_in_user(&ioc->host_no, &cioc->host_no, sizeof(u16)) || copy_in_user(&ioc->sgl_off, &cioc->sgl_off, sizeof(u32)) || @@ -3010,16 +3011,33 @@ static int __init megasas_init(void) if (rval) { printk(KERN_DEBUG "megasas: PCI hotplug regisration failed \n"); - unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl"); - } - - driver_create_file(&megasas_pci_driver.driver, &driver_attr_version); - driver_create_file(&megasas_pci_driver.driver, - &driver_attr_release_date); - driver_create_file(&megasas_pci_driver.driver, - &driver_attr_dbg_lvl); + goto err_pcidrv; + } + + rval = driver_create_file(&megasas_pci_driver.driver, + &driver_attr_version); + if (rval) + goto err_dcf_attr_ver; + rval = driver_create_file(&megasas_pci_driver.driver, + &driver_attr_release_date); + if (rval) + goto err_dcf_rel_date; + rval = driver_create_file(&megasas_pci_driver.driver, + &driver_attr_dbg_lvl); + if (rval) + goto err_dcf_dbg_lvl; return rval; +err_dcf_dbg_lvl: + driver_remove_file(&megasas_pci_driver.driver, + &driver_attr_release_date); +err_dcf_rel_date: + driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version); +err_dcf_attr_ver: + pci_unregister_driver(&megasas_pci_driver); +err_pcidrv: + unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl"); + return rval; } /** @@ -3027,11 +3045,11 @@ static int __init megasas_init(void) */ static void __exit megasas_exit(void) { - driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version); - driver_remove_file(&megasas_pci_driver.driver, - &driver_attr_release_date); driver_remove_file(&megasas_pci_driver.driver, &driver_attr_dbg_lvl); + driver_remove_file(&megasas_pci_driver.driver, + &driver_attr_release_date); + driver_remove_file(&megasas_pci_driver.driver, &driver_attr_version); pci_unregister_driver(&megasas_pci_driver); unregister_chrdev(megasas_mgmt_majorno, "megaraid_sas_ioctl"); |