Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf99dc30 authored by Pan Bian's avatar Pan Bian Committed by Martin K. Petersen
Browse files

scsi: mvsas: replace kfree with scsi_host_put



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: default avatarPan Bian <bianpan2016@163.com>
Reviewed-by: default avatarJack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent bc1371c1
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -557,14 +557,14 @@ static int mvs_pci_init(struct pci_dev *pdev, const struct pci_device_id *ent)
	SHOST_TO_SAS_HA(shost) =
	SHOST_TO_SAS_HA(shost) =
		kcalloc(1, sizeof(struct sas_ha_struct), GFP_KERNEL);
		kcalloc(1, sizeof(struct sas_ha_struct), GFP_KERNEL);
	if (!SHOST_TO_SAS_HA(shost)) {
	if (!SHOST_TO_SAS_HA(shost)) {
		kfree(shost);
		scsi_host_put(shost);
		rc = -ENOMEM;
		rc = -ENOMEM;
		goto err_out_regions;
		goto err_out_regions;
	}
	}


	rc = mvs_prep_sas_ha_init(shost, chip);
	rc = mvs_prep_sas_ha_init(shost, chip);
	if (rc) {
	if (rc) {
		kfree(shost);
		scsi_host_put(shost);
		rc = -ENOMEM;
		rc = -ENOMEM;
		goto err_out_regions;
		goto err_out_regions;
	}
	}