Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752281AbdHHMEB (ORCPT ); Tue, 8 Aug 2017 08:04:01 -0400 Received: from m12-11.163.com ([220.181.12.11]:48768 "EHLO m12-11.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752050AbdHHMDz (ORCPT ); Tue, 8 Aug 2017 08:03:55 -0400 From: Pan Bian To: "James E.J. Bottomley" , "Martin K. Petersen" , Johannes Thumshirn , Jinpu Wang Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: scsi: mvsas: replace kfree with scsi_host_put Date: Tue, 8 Aug 2017 20:02:51 +0800 Message-Id: <1502193771-20271-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: C8CowAB3odh2qIlZQ57YCQ--.23038S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7XF4xuFy7Gr17CF43AF47Arb_yoWDArc_uF W0grn7tr48Gw4fGw10kr45Aryvkan7Was5ur4Fq34fCF1I9r1DZwn29r1rZw4xWa1IkryU uw1DZr4Iyr4UZjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUnaFAJUUUUU== X-Originating-IP: [106.120.213.62] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBURguclaDu9E2YAAAs8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 986 Lines: 34 The return value of scsi_host_alloc() should be released by scsi_host_put(). However, in function mvs_pci_init(), kfree() is used. This patch replaces kfree() with scsi_host_put() to avoid possible memory leaks. Signed-off-by: Pan Bian --- drivers/scsi/mvsas/mv_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c index 4e047b5..75bdb38 100644 --- a/drivers/scsi/mvsas/mv_init.c +++ b/drivers/scsi/mvsas/mv_init.c @@ -557,14 +557,14 @@ static int mvs_pci_init(struct pci_dev *pdev, const struct pci_device_id *ent) SHOST_TO_SAS_HA(shost) = kcalloc(1, sizeof(struct sas_ha_struct), GFP_KERNEL); if (!SHOST_TO_SAS_HA(shost)) { - kfree(shost); + scsi_host_put(shost); rc = -ENOMEM; goto err_out_regions; } rc = mvs_prep_sas_ha_init(shost, chip); if (rc) { - kfree(shost); + scsi_host_put(shost); rc = -ENOMEM; goto err_out_regions; } -- 1.9.1