Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3136856pxk; Mon, 7 Sep 2020 04:26:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDe1yyNEUkXfDeLts4saXbrM9usAfzPdLSIJkotv1XgwH4tRg1I+AUAbUyrzgn+UjVEZny X-Received: by 2002:a05:6402:489:: with SMTP id k9mr20908219edv.287.1599477991086; Mon, 07 Sep 2020 04:26:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599477991; cv=none; d=google.com; s=arc-20160816; b=GtyPqGEmvTPq26pJZz7ug4uTiwYyYaCIPP1QGppc+Yh59fwp8prBJpMyzEUem8x4tu 1jFBd7NMsFisONyN729pcB0beQjXUAriIg3lX4sjJYyvr6NiW2NXdJGHWVGutLnAi8Db 9vnawc2fUeiNzJkWfILkw38h+/fVV+LhstalOre4J3UdQLrRE2yNfX/0Z2ElcpHM+qGZ wstx+zkdWCa/lwkF5MpnjT5b8z+2kEwLNZmwcH3yE8IIGgzanuto7j7uVg3hZOUB9HfE TmGj5Pv4Q950UWtAi6+WWGnCnoNn1Z99h/cSess/z+Czw9pJ5ByNdFPVNB3EZ8724TSm KHgg== 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=wI71p+vBP5A7Iy0luzSpVeDW2vV5+x5l4e24GtQPHoo=; b=QaxoF5p5hjBZk/kZoJEgbBphMkoV+fqdV7Jl82dBZMYLCJz1IyvZjggZIGHEJPwMnr gO31GLNe4g42b/AAvo+ClnYZ75IfCYUTPfeHxJAt6NLbhlXyFS/TdvPT6ZBU8LtqDDva n7iqEet9QnnD7U15twEBNr2TJ/igJaKCQG9HIOrrA2+at1qkQ6hHWWXHTRw4DRTWAVde Ac58HL3K1cJCrsvwwMKZE+geIikuOJs/ZMF6P6k+15/8E5uEfkkd0nt4x4fgn8xzV+Rq 13LaxqLnloCQLHQiguJydleYeDqzoK9QCXCMjDba00Z7vJSPhW6X/Qd+v/mnh2pK7W3R quIw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qt16si1888718ejb.352.2020.09.07.04.26.09; Mon, 07 Sep 2020 04:26:31 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728977AbgIGLYN (ORCPT + 99 others); Mon, 7 Sep 2020 07:24:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:47072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728807AbgIGLV6 (ORCPT ); Mon, 7 Sep 2020 07:21:58 -0400 Received: from gaia (unknown [46.69.195.48]) (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 834A0206D4; Mon, 7 Sep 2020 11:21:21 +0000 (UTC) Date: Mon, 7 Sep 2020 12:21:19 +0100 From: Catalin Marinas To: George Cherian Cc: Yang Yingliang , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "will.deacon@arm.com" , "bhelgaas@google.com" , "guohanjun@huawei.com" , Lorenzo Pieralisi Subject: Re: [PATCH] arm64: PCI: fix memleak when calling pci_iomap/unmap() Message-ID: <20200907112118.GD26513@gaia> References: <20200907104546.GC26513@gaia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 + Lorenzo On Mon, Sep 07, 2020 at 10:51:21AM +0000, George Cherian wrote: > Catalin Marinas wrote: > > On Sat, Sep 05, 2020 at 10:48:11AM +0800, Yang Yingliang wrote: > > > diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index > > > 1006ed2d7c604..ddfa1c53def48 100644 > > > --- a/arch/arm64/kernel/pci.c > > > +++ b/arch/arm64/kernel/pci.c > > > @@ -217,4 +217,9 @@ void pcibios_remove_bus(struct pci_bus *bus) > > > acpi_pci_remove_bus(bus); > > > } > > > > > > +void pci_iounmap(struct pci_dev *dev, void __iomem *addr) { > > > + iounmap(addr); > > > +} > > > +EXPORT_SYMBOL(pci_iounmap); > > > > So, what's wrong with the generic pci_iounmap() implementation? > > Shouldn't it call iounmap() already? > > Since ARM64 selects CONFIG_GENERIC_PCI_IOMAP and not > CONFIG_GENERIC_IOMAP, the pci_iounmap function is reduced to a NULL > function. Due to this, even the managed release variants or even the explicit > pci_iounmap calls doesn't really remove the mappings leading to leak. Ah, I missed the fact that pci_iounmap() depends on a different config option. > https://lkml.org/lkml/2020/8/20/28 So is this going to be fixed in the generic code? That would be my preference. A problem with the iounmap() in the proposed patch is that the region may have been an I/O port, so we could end up unmapping the I/O space. -- Catalin