lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAD-N9QUCkaFAGfJ3pzqNoBXqH6rgwg5aHxGqPgdChPRh0_-Lcw@mail.gmail.com>
Date:   Mon, 30 Aug 2021 10:32:48 +0800
From:   Dongliang Mu <mudongliangabcd@...il.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Samuel Iglesias Gonsalvez <siglesias@...lia.com>,
        Jens Taprogge <jens.taprogge@...rogge.org>,
        Lv Yunlong <lyl2019@...l.ustc.edu.cn>,
        Aditya Srivastava <yashsri421@...il.com>,
        Randy Dunlap <rdunlap@...radead.org>,
        industrypack-devel@...ts.sourceforge.net,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] ipack: tpci200: change pci_iounmap to iounmap

On Mon, Aug 30, 2021 at 9:22 AM Dongliang Mu <mudongliangabcd@...il.com> wrote:
>
> On Fri, Aug 27, 2021 at 10:25 PM Greg Kroah-Hartman
> <gregkh@...uxfoundation.org> wrote:
> >
> > On Fri, Aug 27, 2021 at 06:33:46PM +0800, Dongliang Mu wrote:
> > > On Fri, Aug 27, 2021 at 6:00 PM Greg Kroah-Hartman
> > > <gregkh@...uxfoundation.org> wrote:
> > > >
> > > > On Fri, Aug 27, 2021 at 05:43:47PM +0800, Dongliang Mu wrote:
> > > > > The deallocation api for ioremap should be iounmap, other than
> > > > > pci_iounmap.
> > > >
> > > > why?
> > >
> > > Because the tpci200->info->cfg_regs/interface_regs is allocated by
> > > ioremap. From my understanding, ioremap and iounmap are in pairs,
> > > other than pci_iounmap.
> > > See the code below.
> > >
> > > tpci200->info->interface_regs =
> > > ioremap(pci_resource_start(tpci200->info->pdev,
> > >   TPCI200_IP_INTERFACE_BAR),
> > > TPCI200_IFACE_SIZE);
> > >
> > > https://elixir.bootlin.com/linux/latest/source/drivers/ipack/carriers/tpci200.c#L297
> > >
> > > tpci200->info->cfg_regs = ioremap(
> > > pci_resource_start(pdev, TPCI200_CFG_MEM_BAR),
> > > pci_resource_len(pdev, TPCI200_CFG_MEM_BAR));
> > >
> > > https://elixir.bootlin.com/linux/latest/source/drivers/ipack/carriers/tpci200.c#L546
> > >
> > > If there is any issue, please let me know
> >
> > The point is that the driver should be calling pci_iomap_bar() instead
> > of ioremap(), and then the call to pci_ioumap() is correct here.

Hi gregkh,

For cfg_regs [1], it is fine to change from:

tpci200->info->cfg_regs = ioremap(
pci_resource_start(pdev, TPCI200_CFG_MEM_BAR),
pci_resource_len(pdev, TPCI200_CFG_MEM_BAR));

to :

tpci200->info->cfg_regs = pci_ioremap_bar(pdev, TPCI200_CFG_MEM_BAR);

But for interface_regs [2], I am not sure as TPCI200_IFACE_SIZE is a
totally separate definition, not calculated by resouce_size or
pci_resource_len(tpci200->info->pdev, TPCI200_IP_INTERFACE_BAR).

tpci200->info->interface_regs =
ioremap(pci_resource_start(tpci200->info->pdev,
  TPCI200_IP_INTERFACE_BAR),
TPCI200_IFACE_SIZE);

#define TPCI200_IFACE_SIZE            0x100

Any comment here?

Note that, it is pci_ioremap_bar, not pci_iomap_bar.

[1] https://elixir.bootlin.com/linux/v5.14/source/drivers/ipack/carriers/tpci200.c#L544
[2] https://elixir.bootlin.com/linux/v5.14/source/drivers/ipack/carriers/tpci200.c#L295

> >
> > Please make that change instead.
>
> No problem. I will modify the patch and send a v2 patch afterwards.
>
> >
> > thanks,
> >
> > greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ