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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190807220837.GZ151852@google.com>
Date:   Wed, 7 Aug 2019 17:08:37 -0500
From:   Bjorn Helgaas <helgaas@...nel.org>
To:     Marc Gonzalez <marc.w.gonzalez@...e.fr>
Cc:     Stephen Boyd <swboyd@...omium.org>,
        LKML <linux-kernel@...r.kernel.org>,
        PCI <linux-pci@...r.kernel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
        Lucas Stach <l.stach@...gutronix.de>,
        Linus Walleij <linus.walleij@...aro.org>,
        Mans Rullgard <mans@...sr.com>, Marc Zyngier <maz@...nel.org>
Subject: Re: [PATCH v6 31/57] pci: Remove dev_err() usage after
 platform_get_irq()

On Wed, Aug 07, 2019 at 04:09:10PM +0200, Marc Gonzalez wrote:
> On 30/07/2019 23:56, Bjorn Helgaas wrote:
> 
> >> diff --git a/drivers/pci/controller/pcie-tango.c b/drivers/pci/controller/pcie-tango.c
> >> index 21a208da3f59..b87aa9041480 100644
> >> --- a/drivers/pci/controller/pcie-tango.c
> >> +++ b/drivers/pci/controller/pcie-tango.c
> >> @@ -273,10 +273,8 @@ static int tango_pcie_probe(struct platform_device *pdev)
> >>  		writel_relaxed(0, pcie->base + SMP8759_ENABLE + offset);
> >>  
> >>  	virq = platform_get_irq(pdev, 1);
> >> -	if (virq <= 0) {
> >> -		dev_err(dev, "Failed to map IRQ\n");
> >> +	if (virq <= 0)
> >>  		return -ENXIO;
> >
> > Why <= 0 and -ENXIO?
> 
> Smirk. I remember discussing this in the past...
> Here it is:
> 
> 	https://patchwork.kernel.org/patch/10006651/

Sigh, what a mess.  I did say in that discussion that it wasn't worth
changing existing "irq <= 0" tests.  I can't remember why I said that,
but I think I was wrong.

platform_get_irq() is a generic interface and we have to be able to
interpret return values consistently.  The overwhelming consensus
among platform_get_irq() callers is to treat "irq < 0" as an error,
and I think we should follow suit.

> A) AFAIU platform_get_irq() = 0 signals an error.
> 
> 	https://yarchive.net/comp/linux/zero.html
> 	https://lkml.org/lkml/2016/2/9/212
> 	https://patchwork.ozlabs.org/patch/486056/
> 
> B) I don't remember why I picked ENXIO.
> Perhaps it made more sense to me (at the time) than EINVAL or ENODEV.

I think the best pattern is:

  irq = platform_get_irq(pdev, i);
  if (irq < 0)
    return irq;

There's not an overwhelming consensus on whether to return the result
of platform_get_irq() or a hard-coded -ENXIO/-EINVAL/-ENODEV etc, but
why throw away information?

Bjorn

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ