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]
Date:   Tue, 25 Jan 2022 12:02:45 -0600
From:   Terry Bowman <Terry.Bowman@....com>
To:     Jean Delvare <jdelvare@...e.de>
Cc:     linux@...ck-us.net, linux-watchdog@...r.kernel.org,
        linux-i2c@...r.kernel.org, wsa@...nel.org,
        andy.shevchenko@...il.com, rafael.j.wysocki@...el.com,
        linux-kernel@...r.kernel.org, wim@...ux-watchdog.org,
        rrichter@....com, thomas.lendacky@....com,
        Nehal-bakulchandra.Shah@....com, Basavaraj.Natikar@....com,
        Shyam-sundar.S-k@....com, Mario.Limonciello@....com
Subject: Re: [PATCH v3 2/4] Watchdog: sp5100_tco: Refactor MMIO base address
 initialization



On 1/25/22 10:38 AM, Jean Delvare wrote:
> On Tue, 25 Jan 2022 09:18:59 -0600, Terry Bowman wrote:
>> On 1/25/22 7:45 AM, Jean Delvare wrote:
>>> On Tue, 18 Jan 2022 14:22:32 -0600, Terry Bowman wrote:  
>>>> +static int __sp5100_tco_prepare_base(struct sp5100_tco *tco,
>>>> +				     u32 mmio_addr,
>>>> +				     const char *dev_name)
>>>> +{
>>>> +	struct device *dev = tco->wdd.parent;
>>>> +	int ret = 0;
>>>> +
>>>> +	if (!mmio_addr)
>>>> +		return -ENOMEM;  
>>>
>>> Can this actually happen? If it does, is -ENOMEM really the best error
>>> value?
>>
>> This can happen if mmio_addr is not assigned in sp5100_tco_setupdevice_mmio() 
>> before calling sp5100_tco_prepare_base() and __sp5100_tco_prepare_base().
> 
> Ah yes, I can see it now.
> 
>> I can move the NULL check out of __sp5100_tco_prepare_base() and into
>> sp5100_tco_prepare_base() before calling __sp5100_tco_prepare_base().
>> As you describe below.
>>
>> The ENOMEM return value should be interpreted as the mmio_addr is not 
>> available. EBUSY does not describe the failure correctly because EBUSY 
>> implies the resource is present and normally available but not available 
>> at this time. Do you have a return value preference ?
> 
> Well, if one mmio_addr isn't set, you shouldn't call
> __sp5100_tco_prepare_base() for it so there's no error to return. If
> neither mmio_addr is set then the hardware is simply not configured to
> be used, so that would be a -NODEV returned by
> sp5100_tco_prepare_base() I suppose?

I agree, -NODEV communicates the error status better.

> 
> BTW...
>  
>>>> (...)
>>>> +	if (ret)
>>>> +		dev_err(dev, "Failed to reserve-map MMIO (%X) and alternate MMIO (%X) regions. ret=%X",
>>>> +			mmio_addr, alt_mmio_addr, ret);  
> 
> ... I think that should be a "or" rather than "and", and singular
> "region", in this error message? I mean, the plan was never to
> reserve-map both of them, if I understand correctly.
> 

This dev_err() is executed when both mmio_addr and alt_mmio_addr addresses failed either 
devm_request_mem_region() or failed devm_ioremap(). I think the following would be most accurate:

dev_err(dev, 
        "Failed to reserve or map the MMIO (0x%X) and alternate MMIO (0x%X) regions, ret=%d",
        mmio_addr, alt_mmio_addr, ret);  

Above is my preference but I don't have a strong opinion. Providing the address and error code 
information in the message is most important. I will make the change as you requested. 

Regards,
Terry



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ