All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Ladislav Michl <ladis@linux-mips.org>,
	Wei Yongjun <weiyongjun1@huawei.com>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-omap@vger.kernel.org, linux-pci@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH -next] PCI: dra7xx: Fix potential NULL dereference
Date: Fri, 16 Nov 2018 11:51:29 +0000	[thread overview]
Message-ID: <20181116115129.GA3228@e107981-ln.cambridge.arm.com> (raw)
In-Reply-To: <20180120001645.GA21343@lenoch>

On Sat, Jan 20, 2018 at 01:16:45AM +0100, Ladislav Michl wrote:
> On Fri, Jan 19, 2018 at 06:06:57PM +0100, Ladislav Michl wrote:
> > On Fri, Jan 19, 2018 at 10:58:57AM +0100, Ladislav Michl wrote:
> > > On Thu, Jan 18, 2018 at 12:35:25PM -0600, Bjorn Helgaas wrote:
> > > > That's probably a better idea.  Maybe we should add a comment like this
> > > > to help avoid this in the future:
> > > 
> > > That seems to spot another a bit more serious problem (given how late
> > > release cycle is now).
> > > 
> > > Both devm_ioremap() and devm_ioremap_resource() shares the same release
> > > function: devm_ioremap_release(). However this function is not aware of
> > > memory region previously requested by devm_request_mem_region() called
> > > from devm_ioremap_resource().
> > > 
> > > Bellow is just a quick hack, even untested as looking at devm_ioremap,
> > > devm_ioremap_wc and devm_ioremap_wc, there is some room for optimization.
> > 
> > Okay, forget it, above analysis is not correct, however there is a bug (and
> > also in PCI version). To show it, let's make following modification:
> 
> I will never ever work in single tree for two different boards without full
> recompile (which should save time and caused opposite) as it makes debugging
> pointless - there is no bug.
> 
> As a request forgiveness, please accept following draft as proposed solution
> for $subj

Wei, Ladislav,

getting back to this old thread, I would mark it as "changes requested"
and expect someone to post a follow-up patch, I do not think this is
a solved problem.

Lorenzo

> Subject: [PATCH] PCI: dra7xx: Use devm_ioremap_resource()
> 
> diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c
> index 8bf7c2714db6..7f422ae258ac 100644
> --- a/drivers/pci/dwc/pci-dra7xx.c
> +++ b/drivers/pci/dwc/pci-dra7xx.c
> @@ -409,14 +409,14 @@ static int __init dra7xx_add_pcie_ep(struct dra7xx_pcie *dra7xx,
>  	ep->ops = &pcie_ep_ops;
>  
>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ep_dbics");
> -	pci->dbi_base = devm_ioremap(dev, res->start, resource_size(res));
> -	if (!pci->dbi_base)
> -		return -ENOMEM;
> +	pci->dbi_base = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(pci->dbi_base))
> +		return PTR_ERR(pci->dbi_base);
>  
>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ep_dbics2");
> -	pci->dbi_base2 = devm_ioremap(dev, res->start, resource_size(res));
> -	if (!pci->dbi_base2)
> -		return -ENOMEM;
> +	pci->dbi_base2 = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(pci->dbi_base2))
> +		return PTR_ERR(pci->dbi_base2);
>  
>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space");
>  	if (!res)

      reply	other threads:[~2018-11-16 11:51 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-18 13:54 [PATCH -next] PCI: dra7xx: Fix potential NULL dereference Wei Yongjun
2018-01-18 14:00 ` Wei Yongjun
2018-01-18 14:00 ` Wei Yongjun
2018-01-18 14:42 ` Bjorn Helgaas
2018-01-18 14:42   ` Bjorn Helgaas
2018-01-18 14:54 ` Ladislav Michl
2018-01-18 14:54   ` Ladislav Michl
2018-01-18 18:35   ` Bjorn Helgaas
2018-01-18 18:35     ` Bjorn Helgaas
2018-01-18 21:34     ` Ladislav Michl
2018-01-18 21:34       ` Ladislav Michl
2018-01-19  1:54       ` weiyongjun (A)
2018-01-19  1:54         ` weiyongjun (A)
2018-01-19  1:54         ` weiyongjun (A)
2018-01-19  5:56         ` Julia Lawall
2018-01-19  5:56           ` Julia Lawall
2018-01-19  7:03         ` Ladislav Michl
2018-01-19  7:03           ` Ladislav Michl
2018-01-19  9:16           ` Ladislav Michl
2018-01-19  9:16             ` Ladislav Michl
2018-01-19  9:58     ` Ladislav Michl
2018-01-19  9:58       ` Ladislav Michl
2018-01-19 17:06       ` Ladislav Michl
2018-01-19 17:06         ` Ladislav Michl
2018-01-20  0:16         ` Ladislav Michl
2018-01-20  0:16           ` Ladislav Michl
2018-11-16 11:51           ` Lorenzo Pieralisi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181116115129.GA3228@e107981-ln.cambridge.arm.com \
    --to=lorenzo.pieralisi@arm.com \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kishon@ti.com \
    --cc=ladis@linux-mips.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=weiyongjun1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.