Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752182AbdHHPMt (ORCPT ); Tue, 8 Aug 2017 11:12:49 -0400 Received: from m12-13.163.com ([220.181.12.13]:43295 "EHLO m12-13.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752014AbdHHPMs (ORCPT ); Tue, 8 Aug 2017 11:12:48 -0400 Date: Tue, 8 Aug 2017 23:12:28 +0800 From: PanBian To: John Garry , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Linuxarm Subject: Re: scsi: hisi_sas: replace kfree with scsi_host_put Message-ID: <20170808151228.GA32235@bp> Reply-To: PanBian References: <1502192263-12332-1-git-send-email-bianpan2016@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-CM-TRANSID: DcCowABn22Dl1IlZBKHqDQ--.32240S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kry5Ww15Zr1xtFWUKr4kZwb_yoW8Aw13pF ykJrW29F48GF4IgwnruF43Zr1Fgw40q3Z8WFWF9a48Zrn8J34kJr4DCay2gFW5JF4UWF48 JFsrtFyrCa48JFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jC4E_UUUUU= X-Originating-IP: [106.120.213.24] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBZAUuclQG9fT8ZQAAs3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1767 Lines: 64 On Tue, Aug 08, 2017 at 03:56:22PM +0100, John Garry wrote: > 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. Yes, of course. > > John > Thank you, Pan Bian > >--- > > 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); > > > >