From: Thierry Reding <thierry.reding@gmail.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: linux-pwm@vger.kernel.org,
"Mika Penttilä" <mika.penttila@nextfour.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
"Daniel Mack" <daniel@zonque.org>,
"Haojian Zhuang" <haojian.zhuang@gmail.com>,
"Robert Jarzmik" <robert.jarzmik@free.fr>
Subject: Re: [PATCH] pwm: Fill pwm->args before calling pwm_request_from_chip()
Date: Tue, 17 May 2016 13:04:38 +0200 [thread overview]
Message-ID: <20160517110438.GB26166@ulmo.ba.sec> (raw)
In-Reply-To: <1463481333-23438-2-git-send-email-boris.brezillon@free-electrons.com>
[-- Attachment #1: Type: text/plain, Size: 1602 bytes --]
On Tue, May 17, 2016 at 12:35:33PM +0200, Boris Brezillon wrote:
[...]
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 427142d..3d2eeaa 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -143,10 +143,6 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args)
> if (args->args[0] >= pc->npwm)
> return ERR_PTR(-EINVAL);
>
> - pwm = pwm_request_from_chip(pc, args->args[0], NULL);
> - if (IS_ERR(pwm))
> - return pwm;
> -
> pwm->args.period = args->args[1];
>
> if (args->args[2] & PWM_POLARITY_INVERTED)
> @@ -154,6 +150,10 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args)
> else
> pwm->args.polarity = PWM_POLARITY_NORMAL;
>
> + pwm = pwm_request_from_chip(pc, args->args[0], NULL);
> + if (IS_ERR(pwm))
> + return pwm;
> +
Can't do that, because now you're dereferencing an uninitialized
pointer.
> return pwm;
> }
> EXPORT_SYMBOL_GPL(of_pwm_xlate_with_flags);
> @@ -169,12 +169,12 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
> if (args->args[0] >= pc->npwm)
> return ERR_PTR(-EINVAL);
>
> + pwm->args.period = args->args[1];
Same here.
> diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
> index 58b709f..c33bd42 100644
> --- a/drivers/pwm/pwm-pxa.c
> +++ b/drivers/pwm/pwm-pxa.c
> @@ -156,12 +156,12 @@ pxa_pwm_of_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
> {
> struct pwm_device *pwm;
>
> + pwm->args.period = args->args[0];
And here.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: thierry.reding@gmail.com (Thierry Reding)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] pwm: Fill pwm->args before calling pwm_request_from_chip()
Date: Tue, 17 May 2016 13:04:38 +0200 [thread overview]
Message-ID: <20160517110438.GB26166@ulmo.ba.sec> (raw)
In-Reply-To: <1463481333-23438-2-git-send-email-boris.brezillon@free-electrons.com>
On Tue, May 17, 2016 at 12:35:33PM +0200, Boris Brezillon wrote:
[...]
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 427142d..3d2eeaa 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -143,10 +143,6 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args)
> if (args->args[0] >= pc->npwm)
> return ERR_PTR(-EINVAL);
>
> - pwm = pwm_request_from_chip(pc, args->args[0], NULL);
> - if (IS_ERR(pwm))
> - return pwm;
> -
> pwm->args.period = args->args[1];
>
> if (args->args[2] & PWM_POLARITY_INVERTED)
> @@ -154,6 +150,10 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args)
> else
> pwm->args.polarity = PWM_POLARITY_NORMAL;
>
> + pwm = pwm_request_from_chip(pc, args->args[0], NULL);
> + if (IS_ERR(pwm))
> + return pwm;
> +
Can't do that, because now you're dereferencing an uninitialized
pointer.
> return pwm;
> }
> EXPORT_SYMBOL_GPL(of_pwm_xlate_with_flags);
> @@ -169,12 +169,12 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
> if (args->args[0] >= pc->npwm)
> return ERR_PTR(-EINVAL);
>
> + pwm->args.period = args->args[1];
Same here.
> diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
> index 58b709f..c33bd42 100644
> --- a/drivers/pwm/pwm-pxa.c
> +++ b/drivers/pwm/pwm-pxa.c
> @@ -156,12 +156,12 @@ pxa_pwm_of_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
> {
> struct pwm_device *pwm;
>
> + pwm->args.period = args->args[0];
And here.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160517/13bee631/attachment-0001.sig>
next prev parent reply other threads:[~2016-05-17 11:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-17 10:35 [PATCH] pwm: Fill pwm->args before calling pwm_request_from_chip() Boris Brezillon
2016-05-17 10:35 ` Boris Brezillon
2016-05-17 10:35 ` Boris Brezillon
2016-05-17 10:35 ` Boris Brezillon
2016-05-17 11:04 ` Thierry Reding [this message]
2016-05-17 11:04 ` Thierry Reding
2016-05-17 11:11 ` Boris Brezillon
2016-05-17 11:11 ` Boris Brezillon
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=20160517110438.GB26166@ulmo.ba.sec \
--to=thierry.reding@gmail.com \
--cc=boris.brezillon@free-electrons.com \
--cc=daniel@zonque.org \
--cc=haojian.zhuang@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=mika.penttila@nextfour.com \
--cc=robert.jarzmik@free.fr \
/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.