[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e6824330-d331-798d-0f0a-1952db028900@st.com>
Date: Fri, 4 Oct 2019 09:09:51 +0000
From: Benjamin GAIGNARD <benjamin.gaignard@...com>
To: Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>, Yizhuo <yzhai003@....edu>
CC: "linux-pwm@...r.kernel.org" <linux-pwm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Thierry Reding <thierry.reding@...il.com>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Fabrice GASNIER <fabrice.gasnier@...com>,
"linux-stm32@...md-mailman.stormreply.com"
<linux-stm32@...md-mailman.stormreply.com>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>
Subject: Re: [Linux-stm32] [PATCH] pwm: stm32: Fix the usage of uninitialized
variable in stm32_pwm_config()
On 10/4/19 8:23 AM, Uwe Kleine-König wrote:
> Hello,
>
> On Thu, Oct 03, 2019 at 09:46:49PM -0700, Yizhuo wrote:
>> Inside function stm32_pwm_config(), variable "psc" and " arr"
>> could be uninitialized if regmap_read() returns -EINVALs.
>> However, they are used later in the if statement to decide
>> the return value which is potentially unsafe.
Hi Yizhuo,
like for the your patch in IIO trigger regmap_read could only failed
if the hardware block is no more clocked and in this case we won't
return of regmap_read.
Testing regmap_read() return value just add code but doesn't provide a
valid information.
If you really want to log all the possible errors cases please do it in
regmap code itself and
not in *all* the drivers.
Thanks,
Benjamin
>>
>> The same case happens in function stm32_pwm_detect_channels()
>> with variable "ccer", but we cannot just return -EINVAL because
>> the error code is not acceptable by the caller. Aslo, the variable
> s/Aslo/Also/
>
>> "ccer" in functionstm32_pwm_detect_complementary() could also be
> s/functionstm32_pwm_detect_/function stm32_pwm_detect_/
>
>> uninitialized, since stm32_pwm_detect_complementary() returns void,
>> the patch is not easy.
> active_channels() is also affected. Also there are calls to
> regmap_update_bits which should have their return values checked.
>
> While a patch to fix these all is not trivial it is certainly possible
> and I would prefer to fix the problem completely.
>
> Best regards
> Uwe
>
Powered by blists - more mailing lists