Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp534102pxx; Wed, 28 Oct 2020 10:29:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCeeFvRoU8uv41i+SKV6y0V/YQfKeZ8ENGnDZGpczs8g8ShYWTDgsnKlp3o3ctgqIBSQ7W X-Received: by 2002:a17:906:95c5:: with SMTP id n5mr129797ejy.111.1603906157362; Wed, 28 Oct 2020 10:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603906157; cv=none; d=google.com; s=arc-20160816; b=ZvvYjlzSyQnKquQoLfx87Qeb4Z8PVskQRTlFg+qbDcKyZ9o88gPO2rG+XFF1JQ79XU edbi4YkY5dC3G79F32sUsepbLHWCeLIAS74hesZ8b8s8+68Nb4whXO2SH02TWG2gNOI2 hEOdvi0nAzdf/ixiu5kYVXYCz/16hK1QXrzMRD4x7ZP7HM5hV/seMT0PkMdCDw22+geB LIvi4hdlALSjsJmfgvrDFzcnrPTX1rYMW7OYccve0WLSJcGsQkrg/BcrDE4CHQSc0pvL 8vO/6DPCt/S9cC2Od9rweITIvIu0XnBh1KM5yM6hzqk93CflVLWjCdMJBI1zcwUQ8eTF Hlkg== 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=Jj9PLj1Fi+HZLAJX2U+3KUeKhByRzBRqVQlL5Fh0Sns=; b=KU8rpjUHD6WG+r0PPYHc2wXy/QtOOLxfoMNxiYGY4IAarzuRo7rzPwmaNJbQC4xjdc L8zlCcRPD5KTxKMtoHN3bl70bH6BsTdxQDBSO/Sj6uDBGUQ8oZ5eXW86fV5wzCs7DSNU cxUszfn5sAf/GQVDWuF2e1ymNlsJEV/I6avtcG0T5aIjyWuXGCoZ70RBvbM+RrETy9/F KKsn1IHpH6OWUgHzkpon0imAPUDWB6gthwLBdevHLxez3S8kUPiA0bWnGTBLNYmFMFQg JCTyH/pDaspBOAslgutjGjkiTELs+wC50QlK78//WsgRiLOHPvlGLb0GxoeofnUVAmi5 zRxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bwPOeWre; 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 i14si21419edl.282.2020.10.28.10.28.54; Wed, 28 Oct 2020 10:29:17 -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=bwPOeWre; 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 S1821382AbgJ0RnK (ORCPT + 99 others); Tue, 27 Oct 2020 13:43:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:58968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2896804AbgJ0OcI (ORCPT ); Tue, 27 Oct 2020 10:32:08 -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 B5C08206DC; Tue, 27 Oct 2020 14:32:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809128; bh=3q/nnEhu9E96bk/YiAIQUGQn5eWJ44nRaz75oCev4C8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bwPOeWreKnHcbDvrYo7/mFTOA7xbbBx/LMZ/dPrauVSxFBu6kaaKnJU8HyS2SPSF4 lWNRjfL+YAFr4apsMvTCyQnI8MSg2GlJooJWG2g37cT3OJAAqODNO7fgju7oI7F0w4 yDbyUJ6vAteFMU/otZ2ZJz+UJb3ZaDsTshIVmeaA= 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 5.4 055/408] EDAC/i5100: Fix error handling order in i5100_init_one() Date: Tue, 27 Oct 2020 14:49:53 +0100 Message-Id: <20201027135457.615592298@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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 251f2b692785d..0c72daa519ffa 100644 --- a/drivers/edac/i5100_edac.c +++ b/drivers/edac/i5100_edac.c @@ -1074,16 +1074,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; @@ -1149,14 +1148,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