Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9620591imu; Wed, 5 Dec 2018 07:43:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/ULMreYQIOuUcf4dKS3G3jJWCsEfpUJVPXLuN2dIWr78qbH8/NaQANxJqhX4n0ChJK7T6pg X-Received: by 2002:a62:8d4f:: with SMTP id z76mr25646670pfd.2.1544024589128; Wed, 05 Dec 2018 07:43:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544024589; cv=none; d=google.com; s=arc-20160816; b=gle4JS2Guu4Ny63QB3i1J+giO5LqzQu/LX64lgA9Mvj7FXTMj6v9twnz8NLru+HsZv nu78tWzPxhIjNlajGE9SAm0eGkqJ20SsleOKcC9HEbkKb01A1ezt9p0vvpXN0T24cQs6 nYnTkREvHp6DuQ8o7sxy922wesllaPTXFmdGN96sTdnWbEZdjRaJV7O3u9eJz+TvMh3L 4LKyJDJxiTZOdnqwFZZdPM6w2tUIRbdEh/tRSHB4iBgNPkAN4zyz9efC9fBxJYGlsS+F M4derDsA5JAo5vK9oTMtNDdxXSbqcB3WP6Jk/BZnwyJYDQXsex3WTYsQd9Utw9hiX7hy eyxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=N0LZounB0GeMAYDJaiiLNElih5DtzYsNWS1QW8W7rxY=; b=vXuGraE+khBom5xhmqg7e69hFc66UrJzao4NDlK2Q61P25rPxGviSA3u+BjR3A5D3N zT5+R6+OwSREMpmER+7OMktnycvVLiIA1BqyTQhyvrJr6Ylf0tiyhSdDy4ID0qipZPKR LFcW0dDMaXiF/8016y1ukvm5NmEFur9ius9qP4hxijLatZXje54kZab++0Gpl5ymIyQ7 KVP4CepDEXgOQ3GRIcSrG3Nn/iSWPCwjFwHN2EYHOaa3DWysQ8laV5wjASdIFwmOu0Jc kS47h75A70NiZcfOASd44Y+zTpgPeCJ1P7fqEUVSTwwzNBDSKdMYTfvRdWYMgtx0d681 i2OA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f90si21690967plb.362.2018.12.05.07.42.54; Wed, 05 Dec 2018 07:43:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728208AbeLEPkX (ORCPT + 99 others); Wed, 5 Dec 2018 10:40:23 -0500 Received: from foss.arm.com ([217.140.101.70]:57224 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727876AbeLEPkX (ORCPT ); Wed, 5 Dec 2018 10:40:23 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7711380D; Wed, 5 Dec 2018 07:40:22 -0800 (PST) Received: from e107981-ln.cambridge.arm.com (e107981-ln.cambridge.arm.com [10.1.197.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CCCD03F5AF; Wed, 5 Dec 2018 07:40:20 -0800 (PST) Date: Wed, 5 Dec 2018 15:40:13 +0000 From: Lorenzo Pieralisi To: "Z.q. Hou" Cc: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "bhelgaas@google.com" , "jingoohan1@gmail.com" , "gustavo.pimentel@synopsys.com" , Roy Zang , Mingkai Hu , "M.h. Lian" Subject: Re: [PATCHv2 1/4] PCI: dwc: fix potential memory leak Message-ID: <20181205154013.GA18294@e107981-ln.cambridge.arm.com> References: <20181107100854.28389-1-Zhiqiang.Hou@nxp.com> <20181107100854.28389-2-Zhiqiang.Hou@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181107100854.28389-2-Zhiqiang.Hou@nxp.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 07, 2018 at 10:09:04AM +0000, Z.q. Hou wrote: > From: Hou Zhiqiang > > Free the allocated pci_host_bridge struct when failed to get > host bridge resources, and free the resource windows before > free the bridge. > > Signed-off-by: Hou Zhiqiang > Acked-by: Gustavo Pimentel > --- > V2: > - Reworded the subject. > > drivers/pci/controller/dwc/pcie-designware-host.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c > index 29a05759a294..ecacce016489 100644 > --- a/drivers/pci/controller/dwc/pcie-designware-host.c > +++ b/drivers/pci/controller/dwc/pcie-designware-host.c > @@ -353,7 +353,7 @@ int dw_pcie_host_init(struct pcie_port *pp) > ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, > &bridge->windows, &pp->io_base); > if (ret) > - return ret; > + goto error; > > ret = devm_request_pci_bus_resources(dev, &bridge->windows); > if (ret) > @@ -502,6 +502,7 @@ int dw_pcie_host_init(struct pcie_port *pp) > return 0; > > error: > + pci_free_resource_list(&bridge->windows); This would cause a double-free, devm_request_pci_bus_resource already takes care of freeing resources, patch dropped. Lorenzo > pci_free_host_bridge(bridge); > return ret; > } > -- > 2.17.1 >