* [PATCH] aic94xx: set error code on an error path in aic94xx_init
@ 2018-05-31 18:28 Peter Melnichenko
2018-05-31 19:15 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Peter Melnichenko @ 2018-05-31 18:28 UTC (permalink / raw)
To: James E.J. Bottomley
Cc: Peter Melnichenko, Martin K. Petersen, linux-scsi, linux-kernel,
ldv-project
When sas_domain_attach_transport returns NULL, aic94xx_init
frees acquired resources but returns err equal to 0, as
assigned by a previous statement.
The patch sets err to -ENOMEM before jumping to the error label.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Peter Melnichenko <melnichenko@ispras.ru>
---
drivers/scsi/aic94xx/aic94xx_init.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index 6c83886..4a4746c 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 = -ENOMEM;
goto out_destroy_caches;
+ }
err = pci_register_driver(&aic94xx_pci_driver);
if (err)
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] aic94xx: set error code on an error path in aic94xx_init
2018-05-31 18:28 [PATCH] aic94xx: set error code on an error path in aic94xx_init Peter Melnichenko
@ 2018-05-31 19:15 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2018-05-31 19:15 UTC (permalink / raw)
To: Peter Melnichenko
Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi,
Linux Kernel Mailing List, ldv-project
On Thu, May 31, 2018 at 9:28 PM, Peter Melnichenko
<melnichenko@ispras.ru> wrote:
> When sas_domain_attach_transport returns NULL, aic94xx_init
> frees acquired resources but returns err equal to 0, as
> assigned by a previous statement.
>
> The patch sets err to -ENOMEM before jumping to the error label.
Wouldn't be better to fix a callee to return proper error code and...
> aic94xx_transport_template =
> sas_domain_attach_transport(&aic94xx_transport_functions);
> - if (!aic94xx_transport_template)
> + if (!aic94xx_transport_template) {
> + err = -ENOMEM;
> goto out_destroy_caches;
> + }
this becomes
err = _attach_();
if (err < 0)
goto ;
_template = err;
?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-31 19:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-31 18:28 [PATCH] aic94xx: set error code on an error path in aic94xx_init Peter Melnichenko
2018-05-31 19:15 ` Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.