From patchwork Thu Aug 10 16:09:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 109817 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp2559856obb; Thu, 10 Aug 2017 08:43:01 -0700 (PDT) X-Received: by 10.84.218.3 with SMTP id q3mr13628583pli.282.1502379781846; Thu, 10 Aug 2017 08:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502379781; cv=none; d=google.com; s=arc-20160816; b=Xp86lBLnG6vXv4k1UjWuXYb50WCPfDKSR3W74MTuuT0ps5NsGef0J2W5mXsIgTZxZS /3ti3diud4U0ZOoftRLzXZGzxmHNIQzHsKNHvQRM5zJeHAWz/mFpoRwKENcJNVsUfzdZ dYeftgG62F8t2aGV9LVIwrO+HAT0j1/QtkYhBo89K2b0f9GVR9lxOe3GtnUD9nQx2pwN fC4b4DCNT2gK3M9A9p8AIK4BuqBLbaB20L0+mWsq9HcrDQ9UxVB0qKRzH3oLWFkgSd+9 H5yPqijd7cG8U/bk0nId7O+14C5BFdWhaj2e9GpAmtPzi8ze0OnIyJSIzi/MjwzJ4fkd j36w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=iV43jI3giAWxIcCRGkaw/Euo/Z3o6nsQDTyM+Yt0qfk=; b=MQcE0fSKh5nK8I/ULj0zSH0l0IalAfvJs5/nG5zngPegKsQx7H5FoMfxaOWjRDhy87 MEBEZWHCsVD4MFirChawOigNfxNcsoMBGtRa2je/kxcQQ+JxcltwlSOQMpxGDbYYROCT Be3+RUMy5cCiNjvuK4izvhbnB32N1ajmvALIGrjA3nqkKMzIiKGUdXLT+iGgSKyLqg7L 3fnGVvJlzNQaPRRU7+37ekFqNUPwOQfGQ962Q1TZD1m39O6gXPj5FyC+FAjxIgYlPsqs zy+OnMmt3eC+rmaCM04HgMvrRkwlA3HQANqtfSqMFwqd7tJZOy5fQdFZLZMIrHJ9PuH9 0pQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si3994150pgj.524.2017.08.10.08.43.01; Thu, 10 Aug 2017 08:43:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753033AbdHJPm7 (ORCPT + 25 others); Thu, 10 Aug 2017 11:42:59 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3498 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752959AbdHJPmz (ORCPT ); Thu, 10 Aug 2017 11:42:55 -0400 Received: from 172.30.72.58 (EHLO DGGEMS402-HUB.china.huawei.com) ([172.30.72.58]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DEV99173; Thu, 10 Aug 2017 23:42:51 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.301.0; Thu, 10 Aug 2017 23:42:40 +0800 From: John Garry To: , CC: , , , , John Garry Subject: [PATCH 18/19] scsi: hisi_sas: replace kfree with scsi_host_put Date: Fri, 11 Aug 2017 00:09:43 +0800 Message-ID: <1502381384-219889-19-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502381384-219889-1-git-send-email-john.garry@huawei.com> References: <1502381384-219889-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090202.598C7EFC.0091, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: aa0af5180a793c491ab3ef21b0ad5ed5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instances of kfree(shost) should be replaced with scsi_host_put(). In addition, a missing scsi_host_put() is added for error path in hisi_sas_shost_alloc_pci() and v3 driver removal. Signed-off-by: Pan Bian # For main.c changes Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 6 +++--- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 4112afd..9427835 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -1900,7 +1900,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev, return shost; err_out: - kfree(shost); + scsi_host_put(shost); dev_err(dev, "shost alloc failed\n"); return NULL; } @@ -1991,7 +1991,7 @@ int hisi_sas_probe(struct platform_device *pdev, 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); @@ -2006,7 +2006,7 @@ int hisi_sas_remove(struct platform_device *pdev) 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); diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 3620a3e..a20e354 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1811,8 +1811,10 @@ static int soft_reset_v3_hw(struct hisi_hba *hisi_hba) 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; @@ -1833,6 +1835,7 @@ static int soft_reset_v3_hw(struct hisi_hba *hisi_hba) return shost; err_out: + scsi_host_put(shost); dev_err(dev, "shost alloc failed\n"); return NULL; } @@ -1941,7 +1944,7 @@ static int soft_reset_v3_hw(struct hisi_hba *hisi_hba) 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: @@ -1971,14 +1974,16 @@ static void hisi_sas_v3_remove(struct pci_dev *pdev) 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 {