From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Yizhuo <yzhai003@ucr.edu>
Cc: linux-pwm@vger.kernel.org,
Alexandre Torgue <alexandre.torgue@st.com>,
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-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] pwm: stm32: Fix the usage of uninitialized variable in stm32_pwm_config()
Date: Fri, 4 Oct 2019 08:23:36 +0200 [thread overview]
Message-ID: <20191004062336.jidzrytx4z5talro@pengutronix.de> (raw)
In-Reply-To: <20191004044649.2405-1-yzhai003@ucr.edu>
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.
>
> 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
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
_______________________________________________
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 6:23 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 [this message]
2019-10-04 9:09 ` [Linux-stm32] " Benjamin GAIGNARD
2019-10-04 20:08 ` 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=20191004062336.jidzrytx4z5talro@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=alexandre.torgue@st.com \
--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).