From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Benjamin GAIGNARD <benjamin.gaignard@st.com>
Cc: Yizhuo <yzhai003@ucr.edu>,
"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>,
Mark Brown <broonie@kernel.org>
Subject: Re: [Linux-stm32] [PATCH] pwm: stm32: Fix the usage of uninitialized variable in stm32_pwm_config()
Date: Fri, 4 Oct 2019 22:08:04 +0200 [thread overview]
Message-ID: <20191004200804.ee6kedadchxoznnd@pengutronix.de> (raw)
In-Reply-To: <e6824330-d331-798d-0f0a-1952db028900@st.com>
Hello,
Cc += Mark Brown who maintains regmap
On Fri, Oct 04, 2019 at 09:09:51AM +0000, Benjamin GAIGNARD wrote:
>
> 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.
I'm not sure this is aligned with how regmap is supposed to be used. I
think the driver making use of regmap is not supposed to make any
assumptions about how and when a read or write access can or cannot fail
and instead is supposed to check all return values. So IMHO the patch
goes in the right direction.
> 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.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
next prev parent reply other threads:[~2019-10-04 20:08 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 ` [Linux-stm32] " Benjamin GAIGNARD
2019-10-04 20:08 ` Uwe Kleine-König [this message]
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=20191004200804.ee6kedadchxoznnd@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=benjamin.gaignard@st.com \
--cc=broonie@kernel.org \
--cc=fabrice.gasnier@st.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=thierry.reding@gmail.com \
--cc=yzhai003@ucr.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).