From: Benjamin GAIGNARD <benjamin.gaignard@st•com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix•de>,
Yizhuo <yzhai003@ucr•edu>
Cc: "linux-pwm@vger•kernel.org" <linux-pwm@vger•kernel.org>,
"linux-kernel@vger•kernel.org" <linux-kernel@vger•kernel.org>,
Thierry Reding <thierry.reding@gmail•com>,
Maxime Coquelin <mcoquelin.stm32@gmail•com>,
Fabrice GASNIER <fabrice.gasnier@st•com>,
"linux-stm32@st-md-mailman•stormreply.com"
<linux-stm32@st-md-mailman•stormreply.com>,
"linux-arm-kernel@lists•infradead.org"
<linux-arm-kernel@lists•infradead.org>
Subject: Re: [Linux-stm32] [PATCH] pwm: stm32: Fix the usage of uninitialized variable in stm32_pwm_config()
Date: Fri, 4 Oct 2019 09:09:51 +0000 [thread overview]
Message-ID: <e6824330-d331-798d-0f0a-1952db028900@st.com> (raw)
In-Reply-To: <20191004062336.jidzrytx4z5talro@pengutronix.de>
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
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-10-04 9:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-04 4:46 [PATCH] pwm: stm32: Fix the usage of uninitialized variable in stm32_pwm_config() Yizhuo
2019-10-04 6:23 ` Uwe Kleine-König
2019-10-04 9:09 ` Benjamin GAIGNARD [this message]
2019-10-04 20:08 ` [Linux-stm32] " Uwe Kleine-König
2019-10-04 20:26 ` Mark Brown
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=e6824330-d331-798d-0f0a-1952db028900@st.com \
--to=benjamin.gaignard@st$(echo .)com \
--cc=fabrice.gasnier@st$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-pwm@vger$(echo .)kernel.org \
--cc=linux-stm32@st-md-mailman$(echo .)stormreply.com \
--cc=mcoquelin.stm32@gmail$(echo .)com \
--cc=thierry.reding@gmail$(echo .)com \
--cc=u.kleine-koenig@pengutronix$(echo .)de \
--cc=yzhai003@ucr$(echo .)edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox