Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3193600yba; Tue, 16 Apr 2019 06:40:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwL1MUHo5hDKWmhv/iLF1mDs2St5CxjlLbBR+qrdjdR3W1RJ39k89Qbn21xXq+uYT9jlsqY X-Received: by 2002:a62:70c6:: with SMTP id l189mr83861582pfc.139.1555422016658; Tue, 16 Apr 2019 06:40:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555422016; cv=none; d=google.com; s=arc-20160816; b=oIdpuqKcy1z36oUij2A6keS2j0j+LE+XYMf04PgeCeyATmHf3lIad2iDnRf8vqB3rB kyeQsWxbFrAdXk8Gaeb7SOhyVCz17bgFpv39Z7BmizmYshtd30ITGazAzvqLnAUUNARH 3q5HJ6ybutZ5Yg885UJTsCA2R/9W5JjaampFV70/wSmtRNJ27G/FywG+/kO/6RDBDn80 4I584sqjHbkFD9X9BzUzBC2BVRJWUn3b4UTph7pTtanq6gKq/QZrQ6LtKKEKNn64P2iP KA0AdroZHa6bOuZhKLb69LuRtrnfprEENqBAT1PfvyhUI36tjE77RWpL/b0hH5+xnscj keYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rbLD62eCR0P7Q+kLTsPo2FJZKndewhqOClWXt9RXgQc=; b=FDV6FmV+Y2Vcp+IUUcGy6A2nMpOJTW84b0RWFBTXxKChKyWRJaQHhG51xJik1hhrwV w0CZbgItXJVSzxZjr9BmdPAaF3xIqxMPMBx/xpDwMikvXDEAW9akWPVb/pqWw4rOmCej nvWhEqGlqe9BmC56mS9qRrAoY6is5Rixp+i1IjxTDIQ9URY2iUr/05yE8rczq0Q4lc6a UTaDxG5DW2AboMuTxauXPP/5SWol3ev4itY7rS/b7C681bX+ohaQ7sbR4ZWn6/paVUNZ kOiSmAbHEeqT+Az7WqH2svHz7yUrM6cXAh7ajoRAOamdvf+hgzW+r1/RQMvG9iArqn8o MMZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=20160920 header.b=nmIYEBBt; 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=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f128si46825860pgc.473.2019.04.16.06.40.00; Tue, 16 Apr 2019 06:40:16 -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=@umn.edu header.s=20160920 header.b=nmIYEBBt; 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=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729399AbfDPNiG (ORCPT + 99 others); Tue, 16 Apr 2019 09:38:06 -0400 Received: from mta-p3.oit.umn.edu ([134.84.196.203]:54582 "EHLO mta-p3.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727136AbfDPNiF (ORCPT ); Tue, 16 Apr 2019 09:38:05 -0400 Received: from localhost (localhost [127.0.0.1]) by mta-p3.oit.umn.edu (Postfix) with ESMTP id E3BDE64B; Tue, 16 Apr 2019 13:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=umn.edu; h= content-type:content-type:subject:subject:message-id:date:date :from:from:in-reply-to:references:mime-version:received:received :received; s=20160920; t=1555421883; x=1557236284; bh=WzjzsrMyXY cT9KJtQRB01ZKYuznxJd30kyzyfTnBhNc=; b=nmIYEBBt2rLaGbmbQ0td8AZ5LZ rlTV8+cZz0//TsrxTKQz/rNRP8sb5CzST8QMfRI6GK/rCYSozVQRZPKX5iJEUHD2 4m3odC6R2aHaCwvU1blyj4aFUwtw9sNsoszs6RcdBzZTctEf8LKHR/GLAjn70twT HoejYfr+pdRY62QEfPpZCN2uYW5GrfjonZVWCP1ipDgPm7L/DEOlwc8RzHLSe6oe WisCwzFE4HxEQ/3/KV79EgR9ftZesm/PUPDzQEQMBsrgkBQhd1Le1pNIl6Ose4w4 YyrcwOXXqNze+LPa+Kt7qorGumXx4ZRFeOoR0gmEEXjja5Gd6vADQr8lbAxg== X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p3.oit.umn.edu ([127.0.0.1]) by localhost (mta-p3.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zFND8aQT-eRu; Tue, 16 Apr 2019 08:38:03 -0500 (CDT) Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: wang6495) by mta-p3.oit.umn.edu (Postfix) with ESMTPSA id A5806516; Tue, 16 Apr 2019 08:38:03 -0500 (CDT) Received: by mail-io1-f41.google.com with SMTP id f6so17645999iop.3; Tue, 16 Apr 2019 06:38:03 -0700 (PDT) X-Gm-Message-State: APjAAAU5HFRWUg8R9xzxb/zEkbG5rRPOp6ht2YG0xVtmz0vEbNTqpbAj qsmawl9cQOZcHP7CQaUazUaIcVBho68tK9yhQEg= X-Received: by 2002:a6b:e50a:: with SMTP id y10mr1277286ioc.91.1555421883470; Tue, 16 Apr 2019 06:38:03 -0700 (PDT) MIME-Version: 1.0 References: <1555340058-3065-1-git-send-email-wang6495@umn.edu> <20190416072327.GA127769@gmail.com> In-Reply-To: <20190416072327.GA127769@gmail.com> From: Wenwen Wang Date: Tue, 16 Apr 2019 08:37:27 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86/PCI: fix a memory leak bug To: Ingo Molnar Cc: Bjorn Helgaas , 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)" , Wenwen Wang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 16, 2019 at 2:23 AM Ingo Molnar wrote: > > > * 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 can lead to > > a memory leak bug. > > > > To fix this issue, this patch frees the allocated table if it is not used. > > > > Signed-off-by: Wenwen Wang > > --- > > 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..d9bcb96 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 *itable = NULL; > > + > > Minor style nit: the canonical name of irq_routing_table local variables > is usually 'rtable' or 'rt' - let's not add a third naming variant with > 'itable'? > Thanks for your comment! I will rework the patch. Wenwen > > 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(); > > + itable = 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(itable); > > pirq_table = NULL; > > + } > > Reviewed-by: Ingo Molnar > > Thanks, > > Ingo