scsi: mvsas: replace kfree with scsi_host_put
authorPan Bian <bianpan2016@163.com>
Tue, 8 Aug 2017 12:02:51 +0000 (20:02 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 10 Aug 2017 23:55:35 +0000 (19:55 -0400)
The return value of scsi_host_alloc() should be released by
scsi_host_put(). However, in function mvs_pci_init(), kfree()
is used. This patch replaces kfree() with scsi_host_put() to avoid
possible memory leaks.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/mvsas/mv_init.c

index 1d53410334ccdc3d5a4a381529d6e13f5fb121a3..f0a096a1e27643384663a134b4b96cd25bc979ec 100644 (file)
@@ -557,14 +557,14 @@ static int mvs_pci_init(struct pci_dev *pdev, const struct pci_device_id *ent)
        SHOST_TO_SAS_HA(shost) =
                kcalloc(1, sizeof(struct sas_ha_struct), GFP_KERNEL);
        if (!SHOST_TO_SAS_HA(shost)) {
-               kfree(shost);
+               scsi_host_put(shost);
                rc = -ENOMEM;
                goto err_out_regions;
        }
 
        rc = mvs_prep_sas_ha_init(shost, chip);
        if (rc) {
-               kfree(shost);
+               scsi_host_put(shost);
                rc = -ENOMEM;
                goto err_out_regions;
        }