From patchwork Wed Feb 11 04:58:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 5810201 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E7909BF440 for ; Wed, 11 Feb 2015 04:58:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21BA920218 for ; Wed, 11 Feb 2015 04:58:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 422FD2017E for ; Wed, 11 Feb 2015 04:58:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752156AbbBKE6b (ORCPT ); Tue, 10 Feb 2015 23:58:31 -0500 Received: from foss-mx-na.arm.com ([217.140.108.86]:43005 "EHLO foss-mx-na.foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751765AbbBKE6a (ORCPT ); Tue, 10 Feb 2015 23:58:30 -0500 Received: from foss-smtp-na-1.foss.arm.com (unknown [10.80.61.8]) by foss-mx-na.foss.arm.com (Postfix) with ESMTP id CFFA54E1; Tue, 10 Feb 2015 22:58:20 -0600 (CST) Received: from collaborate-mta1.arm.com (highbank-bc01-b06.austin.arm.com [10.112.81.134]) by foss-smtp-na-1.foss.arm.com (Postfix) with ESMTP id B085F5FAC1; Tue, 10 Feb 2015 22:58:19 -0600 (CST) Received: from red-moon.cambridge.arm.com (red-moon.cambridge.arm.com [10.1.203.137]) by collaborate-mta1.arm.com (Postfix) with ESMTP id A6AA713F638; Tue, 10 Feb 2015 22:58:18 -0600 (CST) From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Cc: jiang.liu@linux.intel.com, Lorenzo Pieralisi , Bjorn Helgaas , "Rafael J. Wysocki" Subject: [PATCH] drivers: of: pci: remove duplicate kfree in of_pci_get_host_bridge_resources Date: Wed, 11 Feb 2015 04:58:35 +0000 Message-Id: <1423630715-23568-1-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.2.1 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit d2be00c0fb5a ("of/pci: Free resources on failure in of_pci_get_host_bridge_resources()") fixed the error code path in of_pci_get_host_bridge_resources() by adding code that runs through the resources list to free all resources in it and then calls kfree on the bus_range resource pointer to complete the memory deallocation. Since the bus_range resource is added to the resources list through pci_add_resource, the resource_list_for_each_entry loop in the error exit path frees it already and freeing it anew could trigger a double free, hence this patch removes the superfluos kfree call on the bus_range resource. Fixes: d2be00c0fb5a ("of/pci: Free resources on failure in of_pci_get_host_bridge_resources()") Signed-off-by: Lorenzo Pieralisi Reported-by: Jiang Liu Cc: Bjorn Helgaas Cc: Rafael J. Wysocki --- drivers/of/of_pci.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c index 110fece..62426d8 100644 --- a/drivers/of/of_pci.c +++ b/drivers/of/of_pci.c @@ -229,7 +229,6 @@ parse_failed: resource_list_for_each_entry(window, resources) kfree(window->res); pci_free_resource_list(resources); - kfree(bus_range); return err; } EXPORT_SYMBOL_GPL(of_pci_get_host_bridge_resources);