return shost;
 err_out:
-       kfree(shost);
+       scsi_host_put(shost);
        dev_err(dev, "shost alloc failed\n");
        return NULL;
 }
        scsi_remove_host(shost);
 err_out_ha:
        hisi_sas_free(hisi_hba);
-       kfree(shost);
+       scsi_host_put(shost);
        return rc;
 }
 EXPORT_SYMBOL_GPL(hisi_sas_probe);
        sas_remove_host(sha->core.shost);
 
        hisi_sas_free(hisi_hba);
-       kfree(shost);
+       scsi_host_put(shost);
        return 0;
 }
 EXPORT_SYMBOL_GPL(hisi_sas_remove);
 
        struct device *dev = &pdev->dev;
 
        shost = scsi_host_alloc(hisi_sas_sht, sizeof(*hisi_hba));
-       if (!shost)
-               goto err_out;
+       if (!shost) {
+               dev_err(dev, "shost alloc failed\n");
+               return NULL;
+       }
        hisi_hba = shost_priv(shost);
 
        hisi_hba->hw = &hisi_sas_v3_hw;
 
        return shost;
 err_out:
+       scsi_host_put(shost);
        dev_err(dev, "shost alloc failed\n");
        return NULL;
 }
 err_out_register_ha:
        scsi_remove_host(shost);
 err_out_ha:
-       kfree(shost);
+       scsi_host_put(shost);
 err_out_regions:
        pci_release_regions(pdev);
 err_out_disable_device:
        struct device *dev = &pdev->dev;
        struct sas_ha_struct *sha = dev_get_drvdata(dev);
        struct hisi_hba *hisi_hba = sha->lldd_ha;
+       struct Scsi_Host *shost = sha->core.shost;
 
        sas_unregister_ha(sha);
        sas_remove_host(sha->core.shost);
 
-       hisi_sas_free(hisi_hba);
        hisi_sas_v3_destroy_irqs(pdev, hisi_hba);
        pci_release_regions(pdev);
        pci_disable_device(pdev);
+       hisi_sas_free(hisi_hba);
+       scsi_host_put(shost);
 }
 
 enum {