From patchwork Wed Aug 26 12:14:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dinghao Liu X-Patchwork-Id: 11738291 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9882C138A for ; Wed, 26 Aug 2020 12:15:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 888312080C for ; Wed, 26 Aug 2020 12:15:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729472AbgHZMPl (ORCPT ); Wed, 26 Aug 2020 08:15:41 -0400 Received: from spam.zju.edu.cn ([61.164.42.155]:47994 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729373AbgHZMPl (ORCPT ); Wed, 26 Aug 2020 08:15:41 -0400 Received: from localhost.localdomain (unknown [210.32.144.184]) by mail-app3 (Coremail) with SMTP id cC_KCgCXP6gxUkZfNt8_Aw--.39637S4; Wed, 26 Aug 2020 20:14:44 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: Borislav Petkov , Mauro Carvalho Chehab , Tony Luck , James Morse , Robert Richter , =?utf-8?q?Niklas_S=C3=B6derlund?= , linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] EDAC: i5100_edac: Fix error handling code in i5100_init_one Date: Wed, 26 Aug 2020 20:14:37 +0800 Message-Id: <20200826121437.31606-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cC_KCgCXP6gxUkZfNt8_Aw--.39637S4 X-Coremail-Antispam: 1UD129KBjvJXoW7KF4rCrWrXFyUuw17WFW8Xrb_yoW8Gr4xpr 9xG34fAry8WayY9r1UAr18XF15tFWqva43KFWxC3y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k List-ID: X-Mailing-List: linux-edac@vger.kernel.org When pci_get_device_func() fails, we don't need to execute pci_dev_put(). But mci should be freed to prevent memleak. When pci_enable_device() fails, we don't need to disable einj either. Fixes: 52608ba205461 ("i5100_edac: probe for device 19 function 0") Signed-off-by: Dinghao Liu --- drivers/edac/i5100_edac.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c index 191aa7c19ded..410bbe55cd3f 100644 --- a/drivers/edac/i5100_edac.c +++ b/drivers/edac/i5100_edac.c @@ -1061,13 +1061,13 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id) PCI_DEVICE_ID_INTEL_5100_19, 0); if (!einj) { ret = -ENODEV; - goto bail_einj; + goto bail_free; } rc = pci_enable_device(einj); if (rc < 0) { ret = rc; - goto bail_disable_einj; + goto bail_einj; } @@ -1136,14 +1136,14 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id) bail_scrub: priv->scrub_enable = 0; cancel_delayed_work_sync(&(priv->i5100_scrubbing)); - edac_mc_free(mci); - -bail_disable_einj: pci_disable_device(einj); bail_einj: pci_dev_put(einj); +bail_free: + edac_mc_free(mci); + bail_disable_ch1: pci_disable_device(ch1mm);