struct clk *refclk;
 
        shost = scsi_host_alloc(&hisi_sas_sht, sizeof(*hisi_hba));
-       if (!shost)
-               goto err_out;
+       if (!shost) {
+               dev_err(dev, "scsi host alloc failed\n");
+               return NULL;
+       }
        hisi_hba = shost_priv(shost);
 
        hisi_hba->hw = hw;
 
        return shost;
 err_out:
+       kfree(shost);
        dev_err(dev, "shost alloc failed\n");
        return NULL;
 }
        int rc, phy_nr, port_nr, i;
 
        shost = hisi_sas_shost_alloc(pdev, hw);
-       if (!shost) {
-               rc = -ENOMEM;
-               goto err_out_ha;
-       }
+       if (!shost)
+               return -ENOMEM;
 
        sha = SHOST_TO_SAS_HA(shost);
        hisi_hba = shost_priv(shost);
 
        arr_phy = devm_kcalloc(dev, phy_nr, sizeof(void *), GFP_KERNEL);
        arr_port = devm_kcalloc(dev, port_nr, sizeof(void *), GFP_KERNEL);
-       if (!arr_phy || !arr_port)
-               return -ENOMEM;
+       if (!arr_phy || !arr_port) {
+               rc = -ENOMEM;
+               goto err_out_ha;
+       }
 
        sha->sas_phy = arr_phy;
        sha->sas_port = arr_port;
-       sha->core.shost = shost;
        sha->lldd_ha = hisi_hba;
 
        shost->transportt = hisi_sas_stt;
 err_out_register_ha:
        scsi_remove_host(shost);
 err_out_ha:
+       hisi_sas_free(hisi_hba);
        kfree(shost);
        return rc;
 }
 {
        struct sas_ha_struct *sha = platform_get_drvdata(pdev);
        struct hisi_hba *hisi_hba = sha->lldd_ha;
+       struct Scsi_Host *shost = sha->core.shost;
 
        scsi_remove_host(sha->core.shost);
        sas_unregister_ha(sha);
        sas_remove_host(sha->core.shost);
 
        hisi_sas_free(hisi_hba);
+       kfree(shost);
        return 0;
 }
 EXPORT_SYMBOL_GPL(hisi_sas_remove);