[PATCH] scsi: fdomain: Fix a resource leak in an error handling path in '__fdomain_16x0_detect()'

From: Christophe JAILLET
Date: Fri Sep 15 2017 - 15:57:14 EST


All error handling paths 'goto fail' in this function.
If 'scsi_register()' fails, we should also go there, otherwise a
'pci_dev_put(pdev)' will be missing.

Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
In order to keep consistance with the rest of the file, I've ignored
checkpatch warnings about spaces vs tabs and indent.
---
drivers/scsi/fdomain.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
index ebbe5a3e665d..0dac03a9c6ed 100644
--- a/drivers/scsi/fdomain.c
+++ b/drivers/scsi/fdomain.c
@@ -960,10 +960,9 @@ struct Scsi_Host *__fdomain_16x0_detect(struct scsi_host_template *tpnt )
get resources. */

shpnt = scsi_register( tpnt, 0 );
- if(shpnt == NULL) {
- release_region(port_base, 0x10);
- return NULL;
- }
+ if (shpnt == NULL)
+ goto fail;
+
shpnt->irq = interrupt_level;
shpnt->io_port = port_base;
shpnt->n_io_port = 0x10;
--
2.11.0