Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4533676yba; Wed, 17 Apr 2019 13:36:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyV4T9KJwbVxGMWlFyT93Wqd410wkosggCU9kfTDDCpfaPIu02AqLFJ+2YqUL4guaqhCWB8 X-Received: by 2002:a17:902:ec0c:: with SMTP id cy12mr69440174plb.291.1555533404384; Wed, 17 Apr 2019 13:36:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555533404; cv=none; d=google.com; s=arc-20160816; b=s9gV1ygmCJoMi/RXrdUMIJExr8KOHezTsfFlx17BvyqXxPR1Ca7I4f01WnsljvAchK k/wptM6SrbeJaYKRPkAb4xxvMwrPLCPPc0rsTiAeje4mzCZ0zHbFpNNZDiipnJaqtAMi c/FRVDX2DAwvyr2W9GdhFYzk5PtAzFSewaRrNK3DjhqCdKV3gYWKm7tG65bpvzISpJ2d wCFXPs+8WsNENzKO6kgMXcrgidDICql5SMJS+VrsDoe06GcQjgb3YjtsUZ9SMrGC9EGk YRJXQSNp8kzgXO4hxogW2nsHQ1tyKrwtON3fMblRMz0L9qOjvWOYipeJnldECf8lFb2Z OFuQ== 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:dkim-signature; bh=2N1On0/kNLD6miU4q1W5rT9CSpdRvAAjQ/g+wOPNPtY=; b=vqphKZTINR5dimeTf9drbDIOhkwTo432jlhBD+a/1pmGcYnczyAW417NnBynur3vsR ERpDjLwbp1Uh959RdziHv7Zy9jwv8TIvEs5YHjVwLeglQlvMtVlJLLL58p0veW7K92FI l2Gpuhz/q4pQE7lND4w+s4Cybujg4cC2gDUoWL/x7WuZBla+8F0GZX8h5eoJJSDOFTJ2 L9/lwd0r7FXX3cFQLh27D3cqCeVmQmc5Un7YiqvFbuerkGRqJ0L9bp6mFwmCaGdQJIXk lauzEYoq0AAwmMUomPjH7l/iTiUkWpyhp7zSGEJnDJPDy0p45iZEjwE9liYkyN5zIp3F GR8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=02FwyfrZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a15si51185581pgd.166.2019.04.17.13.36.29; Wed, 17 Apr 2019 13:36:44 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=02FwyfrZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732749AbfDQUfR (ORCPT + 99 others); Wed, 17 Apr 2019 16:35:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:46722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbfDQUfQ (ORCPT ); Wed, 17 Apr 2019 16:35:16 -0400 Received: from localhost (unknown [69.71.4.100]) (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 9B91B217F4; Wed, 17 Apr 2019 20:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555533315; bh=Us4Mh7NyDCpZ8PIITSv+u78YLzC6mwrmxrBVkQ4WdS4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=02FwyfrZnnCqceCZcyg0aTSI1q6tBoMZKA6mviL57ryyHUJ/R29KCxM9DG5cgT3YE aCZVqqTtqKfWH49R8b28XsXEH1pXOMwqeRXCRTbS1z9nMq4d2Xg5+4iku2MGJ4TqzV kCLxr4oVKT2OU7Qs/8yvVmdrL6OOOXzGNnEScfvw= Date: Wed, 17 Apr 2019 15:35:14 -0500 From: Bjorn Helgaas To: Wenwen Wang Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "open list:PCI SUBSYSTEM" , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH v4] x86/PCI: fix a memory leak bug Message-ID: <20190417203514.GT126710@google.com> References: <1555510730-9060-1-git-send-email-wang6495@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1555510730-9060-1-git-send-email-wang6495@umn.edu> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 17, 2019 at 09:18:50AM -0500, Wenwen Wang wrote: > In pcibios_irq_init(), the PCI IRQ routing table 'pirq_table' is firstly > found through pirq_find_routing_table(). If the table is not found and > 'CONFIG_PCI_BIOS' is defined, the table is then allocated in > pcibios_get_irq_routing_table() using kmalloc(). In the following > execution, if the I/O APIC is used, this table is actually not used. > However, in that case, the allocated table is not freed, which is a memory > leak bug. > > To fix this issue, free the allocated table if it is not used. > > Signed-off-by: Wenwen Wang > Acked-by: Thomas Gleixner I added Ingo's reviewed-by (since the only change from v1 was to make the local variable name change he suggested) and applied this to pci/misc for v5.2, thanks! > --- > arch/x86/pci/irq.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c > index 52e5510..d3a73f9 100644 > --- a/arch/x86/pci/irq.c > +++ b/arch/x86/pci/irq.c > @@ -1119,6 +1119,8 @@ static const struct dmi_system_id pciirq_dmi_table[] __initconst = { > > void __init pcibios_irq_init(void) > { > + struct irq_routing_table *rtable = NULL; > + > DBG(KERN_DEBUG "PCI: IRQ init\n"); > > if (raw_pci_ops == NULL) > @@ -1129,8 +1131,10 @@ void __init pcibios_irq_init(void) > pirq_table = pirq_find_routing_table(); > > #ifdef CONFIG_PCI_BIOS > - if (!pirq_table && (pci_probe & PCI_BIOS_IRQ_SCAN)) > + if (!pirq_table && (pci_probe & PCI_BIOS_IRQ_SCAN)) { > pirq_table = pcibios_get_irq_routing_table(); > + rtable = pirq_table; > + } > #endif > if (pirq_table) { > pirq_peer_trick(); > @@ -1145,8 +1149,10 @@ void __init pcibios_irq_init(void) > * If we're using the I/O APIC, avoid using the PCI IRQ > * routing table > */ > - if (io_apic_assign_pci_irqs) > + if (io_apic_assign_pci_irqs) { > + kfree(rtable); > pirq_table = NULL; > + } > } > > x86_init.pci.fixup_irqs(); > -- > 2.7.4 >