diff mbox series

scsi: aic94xx: fix an error code in aic94xx_init()

Message ID 20180808115640.at6qjutsykgexdt4@kili.mountain (mailing list archive)
State Superseded
Headers show
Series scsi: aic94xx: fix an error code in aic94xx_init() | expand

Commit Message

Dan Carpenter Aug. 8, 2018, 11:56 a.m. UTC
We accidentally return success instead of -ENODEV on this error path.

Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Johannes Thumshirn Aug. 8, 2018, 1:52 p.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
John Garry Aug. 8, 2018, 2:16 p.m. UTC | #2
On 08/08/2018 12:56, Dan Carpenter wrote:
> We accidentally return success instead of -ENODEV on this error path.

Sorry to nitpick, but - as I see - the only way for 
sas_domain_attach_transport() to fail is if the kzalloc() in 
sas_attach_transport() fails, so should this be -ENOMEM? Other drivers 
return this error code for this scenario.

Thanks,
John

>
> Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
> index 80e5b283fd81..cb8191afc1dc 100644
> --- a/drivers/scsi/aic94xx/aic94xx_init.c
> +++ b/drivers/scsi/aic94xx/aic94xx_init.c
> @@ -1030,8 +1030,10 @@ static int __init aic94xx_init(void)
>
>  	aic94xx_transport_template =
>  		sas_domain_attach_transport(&aic94xx_transport_functions);
> -	if (!aic94xx_transport_template)
> +	if (!aic94xx_transport_template) {
> +		err = -ENODEV;
>  		goto out_destroy_caches;
> +	}
>
>  	err = pci_register_driver(&aic94xx_pci_driver);
>  	if (err)
>
>
Dan Carpenter Aug. 8, 2018, 2:25 p.m. UTC | #3
On Wed, Aug 08, 2018 at 03:16:57PM +0100, John Garry wrote:
> On 08/08/2018 12:56, Dan Carpenter wrote:
> > We accidentally return success instead of -ENODEV on this error path.
> 
> Sorry to nitpick, but - as I see - the only way for
> sas_domain_attach_transport() to fail is if the kzalloc() in
> sas_attach_transport() fails, so should this be -ENOMEM? Other drivers
> return this error code for this scenario.
> 

Huh...  I was so sure I looked up other callers to see what people
normally return...  Anyway, you're right.  Let me resend.

regards,
dan carpenter
diff mbox series

Patch

diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index 80e5b283fd81..cb8191afc1dc 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -1030,8 +1030,10 @@  static int __init aic94xx_init(void)
 
 	aic94xx_transport_template =
 		sas_domain_attach_transport(&aic94xx_transport_functions);
-	if (!aic94xx_transport_template)
+	if (!aic94xx_transport_template) {
+		err = -ENODEV;
 		goto out_destroy_caches;
+	}
 
 	err = pci_register_driver(&aic94xx_pci_driver);
 	if (err)