mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@st.com>,
	Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pwm: fix undefined behavior in stm32_pwm_apply
Date: Thu, 26 Jan 2017 12:16:18 +0000	[thread overview]
Message-ID: <20170126121618.s66oob576faozd6z@dell> (raw)
In-Reply-To: <20170125223155.1388582-1-arnd@arndb.de>

On Wed, 25 Jan 2017, Arnd Bergmann wrote:

> The stm32_pwm_apply randomly sets the polarity or doesn't,
> as pointed out by this gcc warning:
> 
> drivers/pwm/pwm-stm32.c: In function 'stm32_pwm_apply':
> drivers/pwm/pwm-stm32.c:204:33: error: 'curstate.polarity' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> I assume it was meant to compare the new state to the current
> state rather than an uninitialized stack variable, so let's
> do that instead.
> 
> Fixes: bafffb6e7bd1 ("pwm: Add driver for STM32 plaftorm")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/pwm/pwm-stm32.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Fix from the author already applied.

> diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
> index ce6232ebefe1..6139512aab7b 100644
> --- a/drivers/pwm/pwm-stm32.c
> +++ b/drivers/pwm/pwm-stm32.c
> @@ -189,7 +189,6 @@ static void stm32_pwm_disable(struct stm32_pwm *priv, int ch)
>  static int stm32_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>  			   struct pwm_state *state)
>  {
> -	struct pwm_state curstate;
>  	bool enabled;
>  	struct stm32_pwm *priv = to_stm32_pwm_dev(chip);
>  	int ret;
> @@ -201,7 +200,7 @@ static int stm32_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
>  		return 0;
>  	}
>  
> -	if (state->polarity != curstate.polarity)
> +	if (state->polarity != pwm->state.polarity)
>  		stm32_pwm_set_polarity(priv, pwm->hwpwm, state->polarity);
>  
>  	ret = stm32_pwm_config(priv, pwm->hwpwm,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

      reply	other threads:[~2017-01-26 12:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-25 22:31 Arnd Bergmann
2017-01-26 12:16 ` Lee Jones [this message]

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=20170126121618.s66oob576faozd6z@dell \
    --to=lee.jones@linaro.org \
    --cc=alexandre.torgue@st.com \
    --cc=arnd@arndb.de \
    --cc=benjamin.gaignard@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=thierry.reding@gmail.com \
    /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

all inboxes | Powered by JetHome®