All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Lee Jones <lee.jones@linaro.org>,
	Fabrice Gasnier <fabrice.gasnier@st.com>,
	linux-pwm@vger.kernel.org
Subject: Re: [PATCH v2 3/3] pwm: stm32: Validate breakinput data from DT
Date: Wed, 16 Oct 2019 15:07:16 +0200	[thread overview]
Message-ID: <20191016130716.GC1772382@ulmo> (raw)
In-Reply-To: <20191016111522.vzsipskmt66q27bq@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 1563 bytes --]

On Wed, Oct 16, 2019 at 01:15:22PM +0200, Uwe Kleine-König wrote:
> On Wed, Oct 16, 2019 at 01:06:01PM +0200, Thierry Reding wrote:
> > Both index and level can only be either 0 or 1 and the filter value is
> > limited to values between (and including) 0 and 15. Validate that the
> > device tree node contains values that are within these ranges.
> > 
> > Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
> > ---
> >  drivers/pwm/pwm-stm32.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
> > index db1d675b45fb..7ff48c14fae8 100644
> > --- a/drivers/pwm/pwm-stm32.c
> > +++ b/drivers/pwm/pwm-stm32.c
> > @@ -530,6 +530,7 @@ static int stm32_pwm_probe_breakinputs(struct stm32_pwm *priv,
> >  				       struct device_node *np)
> >  {
> >  	int nb, ret, array_size;
> > +	unsigned int i;
> >  
> >  	nb = of_property_count_elems_of_size(np, "st,breakinput",
> >  					     sizeof(struct stm32_breakinput));
> > @@ -551,6 +552,13 @@ static int stm32_pwm_probe_breakinputs(struct stm32_pwm *priv,
> >  	if (ret)
> >  		return ret;
> >  
> > +	for (i = 0; i < priv->num_breakinputs; i++) {
> > +		if (priv->breakinputs[i].index > 1 ||
> > +		    priv->breakinputs[i].level > 1 ||
> > +		    priv->breakinputs[i].filter > 15)
> > +			return -EINVAL;
> > +	}
> > +
> 
> maybe put this patch before patch 1 that relies on index not being
> bigger than 1?

Yeah, that's a good idea. Does that resolve the concerns you had on
patch 1?

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-10-16 13:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16 11:05 [PATCH v2 0/3] pwm: stm32: Minor cleanups Thierry Reding
2019-10-16 11:05 ` [PATCH v2 1/3] pwm: stm32: Remove clutter from ternary operator Thierry Reding
2019-10-16 11:11   ` Uwe Kleine-König
2019-10-16 13:06     ` Thierry Reding
2019-10-17  7:23   ` Lee Jones
2019-10-16 11:06 ` [PATCH v2 2/3] pwm: stm32: Pass breakinput instead of its values Thierry Reding
2019-10-16 11:13   ` Uwe Kleine-König
2019-10-16 11:06 ` [PATCH v2 3/3] pwm: stm32: Validate breakinput data from DT Thierry Reding
2019-10-16 11:15   ` Uwe Kleine-König
2019-10-16 13:07     ` Thierry Reding [this message]
2019-10-16 14:35       ` Uwe Kleine-König

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=20191016130716.GC1772382@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=fabrice.gasnier@st.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.