From patchwork Tue Aug 8 12:02:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pan Bian X-Patchwork-Id: 9887695 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 91D3E60352 for ; Tue, 8 Aug 2017 12:04:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 849C1208C2 for ; Tue, 8 Aug 2017 12:04:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 794782522B; Tue, 8 Aug 2017 12:04:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43398208C2 for ; Tue, 8 Aug 2017 12:04:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752278AbdHHMEB (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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=R/j8y3FyepUhvoGeib +01Gz4GfW54WOhF6YRoc+dwg4=; b=oohEtzll8mfrmdV2s8RPU52uiBQqfR3jY5 M5kzHTcBgLjSA75oi0obWdcWdIGjM1bs+xugV6P3kRuGKpAngGLpL7w2Tqhr4gV2 QT6RLksv3jIcwFqxB5rOxsvyfkm+ZY3J0KJrrIz5hzsX8a5nt6r5rt6KAr+bPgzK hbi6vZfgw= Received: from localhost.localdomain (unknown [106.120.213.62]) by smtp7 (Coremail) with SMTP id C8CowAB3odh2qIlZQ57YCQ--.23038S3; Tue, 08 Aug 2017 20:03:04 +0800 (CST) 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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Jack Wang --- 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; }