Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752166AbdHHO4t (ORCPT ); Tue, 8 Aug 2017 10:56:49 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2589 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752010AbdHHO4s (ORCPT ); Tue, 8 Aug 2017 10:56:48 -0400 Subject: Re: scsi: hisi_sas: replace kfree with scsi_host_put To: Pan Bian , "James E.J. Bottomley" , "Martin K. Petersen" References: <1502192263-12332-1-git-send-email-bianpan2016@163.com> CC: , , Linuxarm From: John Garry Message-ID: Date: Tue, 8 Aug 2017 15:56:22 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1502192263-12332-1-git-send-email-bianpan2016@163.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.203.181.152] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.5989D124.01C1,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: c59e0f5269375b5e65914cdac891b4e3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1593 Lines: 55 On 08/08/2017 12:37, Pan Bian wrote: > Return value of scsi_host_alloc() should be released with > scsi_host_put() rather than kfree(). > > Signed-off-by: Pan Bian We also have a kfree(shost) in newly added pci-based v3 driver which would need replacing for consistency. But, apart from that, we seem to have a pre-existing issue in hisi_sas_shost_alloc_pci(), which is missing the shost clean-up for error path. Let me know if you want me to take over this patch and fix up the other places. John > --- > drivers/scsi/hisi_sas/hisi_sas_main.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c > index 4022c3f..22d8922 100644 > --- a/drivers/scsi/hisi_sas/hisi_sas_main.c > +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c > @@ -1825,7 +1825,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; > } > @@ -1916,7 +1916,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); > @@ -1931,7 +1931,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); >