Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp628766pxx; Wed, 28 Oct 2020 12:49:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7mI2OsbRg/lQ2fX+rUsh0ahAjNbpPoJ1jc16pL6WeplF2xu5SVY7BLWcQr+1Fy+Xyvrsj X-Received: by 2002:a50:decd:: with SMTP id d13mr568771edl.202.1603914563471; Wed, 28 Oct 2020 12:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603914563; cv=none; d=google.com; s=arc-20160816; b=bCkbb/UQ8yk6vXLe6n9xh1yPBxDfZrqKk98VtFMnpexSoXVhkufPSIbmd1dNe+j5Fw SqQUy+a8cNqAFlT55RKKAha9RizerOrqvci2UPpLZTxrcBkXbc0mLJm+uozX8zBXDn6f o2Cncf8K6DfwpyaSza+zwoHKU25OKJT8r0adhxya0jU9b6bs6kAdVe+v05SoLxO7Qswf n4TXpiMR5Wzkr/dnS3fuUxFTiR+YtAkFCjNZ0Q8XwnlKBPLP5TZsQzE1wFA1KXmMidZ7 J1TsE6uIsuUyoJwpGLJgozzuLA7ZyshRr1f0gImqqIHKPBi19lOnLevcbpc4sB+h4lDB Y6xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BYR98gFXEJLAeFyXREsjCQtzOTkFt/7f7Y6ORUTg91A=; b=HG5gLTjTcYTJ5SFmYmoDknfK0DhBDz1JQ9Jze44tIjN8yEJrBSz3ARtWGEh4DVOm5x JyNFSlbMlj++VUMMLl/zpC22KXohu5QBRlTkjbriitV4PRrwGPCTX/xa8EqUnqNWO+qP oTSI4jOIM+jas/bU1HdrbG2zrRuU0PZrMI5BazYS44AOO1kmnYU0p0hseHhh5rUH0GRu QDkd6BmMfyhE9D3jQjCLmnV/amws2fwMTe2apgxShrt316cW6wIe+38evzEyjB6z38TF HqPJ+3st2LjTdEgISKiS3wTrI8x/iAGfF3IFeIW67OOVUNp1AVcV5CW24FT4Nql8Q/49 v4BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ijrga37J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w23si165eds.571.2020.10.28.12.49.01; Wed, 28 Oct 2020 12:49:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ijrga37J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1827832AbgJ0S22 (ORCPT + 99 others); Tue, 27 Oct 2020 14:28:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:44022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S368165AbgJ0N5P (ORCPT ); Tue, 27 Oct 2020 09:57:15 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4309D21D7B; Tue, 27 Oct 2020 13:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807034; bh=5k4jKEzXkpTOJwJa1aWqwExMCq4YxvN7L5K90HjaWjo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ijrga37J1FCS4fkxalYL4HFbsTnHy/m4N3hksxUTVs/Jyfdm8YLQA7fEjowtzGdBr r3Fx3WEC+htL9yw9E9rQwRrhWK3ssI2SA2LIaFIBgO3x0hKCA4Z1GZ2yp4TTEb7f8a HjCQmY8+AKhpVQCq3RLJ1VJ1nMHfznDAPgfe/a0U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dinghao Liu , Borislav Petkov , Sasha Levin Subject: [PATCH 4.4 019/112] EDAC/i5100: Fix error handling order in i5100_init_one() Date: Tue, 27 Oct 2020 14:48:49 +0100 Message-Id: <20201027134901.480954454@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dinghao Liu [ Upstream commit 857a3139bd8be4f702c030c8ca06f3fd69c1741a ] When pci_get_device_func() fails, the driver doesn't need to execute pci_dev_put(). mci should still be freed, though, to prevent a memory leak. When pci_enable_device() fails, the error injection PCI device "einj" doesn't need to be disabled either. [ bp: Massage commit message, rename label to "bail_mc_free". ] Fixes: 52608ba205461 ("i5100_edac: probe for device 19 function 0") Signed-off-by: Dinghao Liu Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20200826121437.31606-1-dinghao.liu@zju.edu.cn Signed-off-by: Sasha Levin --- drivers/edac/i5100_edac.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c index 40917775dca1c..59d10f48ed6ab 100644 --- a/drivers/edac/i5100_edac.c +++ b/drivers/edac/i5100_edac.c @@ -1075,16 +1075,15 @@ 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_mc_free; } rc = pci_enable_device(einj); if (rc < 0) { ret = rc; - goto bail_disable_einj; + goto bail_einj; } - mci->pdev = &pdev->dev; priv = mci->pvt_info; @@ -1151,14 +1150,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_mc_free: + edac_mc_free(mci); + bail_disable_ch1: pci_disable_device(ch1mm); -- 2.25.1