diff mbox series

[2/2] scsi: snic: fix refcount leak of shost_gendev in normal path

Message ID 20221103125938.124819-3-yangyingliang@huawei.com
State New
Headers show
Series scsi: snic: fixes two source leaks | expand

Commit Message

Yang Yingliang Nov. 3, 2022, 12:59 p.m. UTC
The refcount of shost_gendev is get snic_tgt_create(), but it
has never been put while module exiting in normal path, so add
put_device() in snic_tgt_dev_release() to avoid refcount leak.

Fixes: c8806b6c9e82 ("snic: driver for Cisco SCSI HBA")
Cc: Karan Tilak Kumar <kartilak@cisco.com>
Cc: Sesidhar Baddela <sebaddel@cisco.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/scsi/snic/snic_disc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/scsi/snic/snic_disc.c b/drivers/scsi/snic/snic_disc.c
index 031c27d8510f..d0759391ed1e 100644
--- a/drivers/scsi/snic/snic_disc.c
+++ b/drivers/scsi/snic/snic_disc.c
@@ -198,6 +198,7 @@  snic_tgt_dev_release(struct device *dev)
 		       dev_name(dev));
 
 	SNIC_BUG_ON(!list_empty(&tgt->list));
+	put_device(dev->parent);
 	kfree(tgt);
 }
 
@@ -303,7 +304,6 @@  snic_tgt_create(struct snic *snic, struct snic_tgt_id *tgtid)
 			      "Snic Tgt: device_add, with err = %d\n",
 			      ret);
 
-		put_device(&snic->shost->shost_gendev);
 		put_device(&tgt->dev);
 		return NULL;
 	}