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: <3d7fc2b4-8f8c-2ad3-34a5-7c48a6832df0@huawei.com>
Date:   Mon, 2 Nov 2020 17:36:25 +0800
From:   Yuehaibing <yuehaibing@...wei.com>
To:     Tomi Valkeinen <tomi.valkeinen@...com>,
        Sam Ravnborg <sam@...nborg.org>
CC:     <a.hajda@...sung.com>, <narmstrong@...libre.com>,
        <Laurent.pinchart@...asonboard.com>, <jonas@...boo.se>,
        <jernej.skrabec@...l.net>, <airlied@...ux.ie>, <daniel@...ll.ch>,
        <sebastian.reichel@...labora.com>,
        <dri-devel@...ts.freedesktop.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drm/bridge: tpd12s015: Fix irq registering in
 tpd12s015_probe

On 2020/11/2 14:57, Tomi Valkeinen wrote:
> On 31/10/2020 09:19, Sam Ravnborg wrote:
>> Hi YueHaibing
>>
>> Thanks for the fix. Appreciated but please update as per comments below.
>>
>> On Sat, Oct 31, 2020 at 11:16:48AM +0800, YueHaibing wrote:
>>> gpiod_to_irq() return negative value in case of error,
>>> the existing code handle negative error codes wrongly.
>>>
>>> Fixes: cff5e6f7e83f ("drm/bridge: Add driver for the TI TPD12S015 HDMI level shifter")
>>> Signed-off-by: YueHaibing <yuehaibing@...wei.com>
>>> ---
>>>  drivers/gpu/drm/bridge/ti-tpd12s015.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/bridge/ti-tpd12s015.c b/drivers/gpu/drm/bridge/ti-tpd12s015.c
>>> index 514cbf0eac75..a18d5197c16c 100644
>>> --- a/drivers/gpu/drm/bridge/ti-tpd12s015.c
>>> +++ b/drivers/gpu/drm/bridge/ti-tpd12s015.c
>>> @@ -160,7 +160,7 @@ static int tpd12s015_probe(struct platform_device *pdev)
>>>  
>>>  	/* Register the IRQ if the HPD GPIO is IRQ-capable. */
>>>  	tpd->hpd_irq = gpiod_to_irq(tpd->hpd_gpio);
>>> -	if (tpd->hpd_irq) {
>>> +	if (tpd->hpd_irq > 0) {
>>>  		ret = devm_request_threaded_irq(&pdev->dev, tpd->hpd_irq, NULL,
>>>  						tpd12s015_hpd_isr,
>>>  						IRQF_TRIGGER_RISING |
>>
>> The current implmentation will skip devm_request_threaded_irq() in case
>> or error - but continue with the rest of the function. So the
>> driver fails to return an error code.
> 
> That is intended. If the HPD gpio supports IRQs (gpiod_to_irq returns a valid number), we use the
> IRQ. If it doesn't (gpiod_to_irq returns an error), it gets polled via detect(). Both are ok.
> 
> I don't know if the gpiod_to_irq never returning 0 is something we should rely on. The docs say
> gpiod_to_irq returns the irq number or an error, so I think checking for >= 0 matches the docs better.
> 

gpiod_to_irq() now never returns 0, see:
https://elixir.bootlin.com/linux/v5.10-rc2/source/drivers/gpio/gpiolib.c#L3183

Also commit 4c37ce8608a8 ("gpio: make gpiod_to_irq() return negative for NO_IRQ") says:

commit 4c37ce8608a8c6521726d4cd1d4f54424e8d095f
Author: Linus Walleij <linus.walleij@...aro.org>
Date:   Mon May 2 13:13:10 2016 +0200

    gpio: make gpiod_to_irq() return negative for NO_IRQ

    If a translation returns zero, that means NO_IRQ, so we
    should return an error since the function is documented to
    return a negative code on error.

So checking for >0 is enough, my patch is correct.

>  Tomi
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ