From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH][next] pinctrl: actions: fix unsigned less than zero comparison
Date: Mon, 02 Jul 2018 12:41:49 +0000 [thread overview]
Message-ID: <20180702122949.GA9925@mani> (raw)
In-Reply-To: <20180702121504.6731-1-colin.king@canonical.com>
Hi Colin,
On Mon, Jul 02, 2018 at 01:15:04PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The check to see if platform_get_irq failed is performed on the
> unsigned value of pctrl->irq[i] and the check is never true because
> an unsigned cannot be less than zero. Fix this by assinging the
> signed int ret to the return of platform_get_irq and checking ret
> instead.
>
Thanks for spotting!
> Detected by CoverityScan, CID#1470247 ("Unsigned comparison against 0")
>
> Fixes: 6c5d0736e9c0 ("pinctrl: actions: Add interrupt support for OWL S900 SoC")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/pinctrl/actions/pinctrl-owl.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pinctrl/actions/pinctrl-owl.c b/drivers/pinctrl/actions/pinctrl-owl.c
> index 4fa9cc377b3b..133ce9e0000a 100644
> --- a/drivers/pinctrl/actions/pinctrl-owl.c
> +++ b/drivers/pinctrl/actions/pinctrl-owl.c
> @@ -1026,11 +1026,10 @@ int owl_pinctrl_probe(struct platform_device *pdev,
> }
>
> for (i = 0; i < pctrl->num_irq ; i++) {
> - pctrl->irq[i] = platform_get_irq(pdev, i);
> - if (pctrl->irq[i] < 0) {
> - ret = pctrl->irq[i];
> + ret = platform_get_irq(pdev, i);
> + pctrl->irq[i] = ret;
Can we move this statement below if condition:
ret = platform_get_irq(pdev, i);
if (ret < 0)
goto err_exit;
pctrl->irq[i] = ret;
This looks slightly better.
Thanks,
Mani
> + if (ret < 0)
> goto err_exit;
> - }
> }
>
> ret = owl_gpio_init(pctrl);
> --
> 2.17.1
>
WARNING: multiple messages have this Message-ID (diff)
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Colin King <colin.king@canonical.com>
Cc: "Andreas Färber" <afaerber@suse.de>,
"Linus Walleij" <linus.walleij@linaro.org>,
linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] pinctrl: actions: fix unsigned less than zero comparison
Date: Mon, 2 Jul 2018 17:59:49 +0530 [thread overview]
Message-ID: <20180702122949.GA9925@mani> (raw)
In-Reply-To: <20180702121504.6731-1-colin.king@canonical.com>
Hi Colin,
On Mon, Jul 02, 2018 at 01:15:04PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The check to see if platform_get_irq failed is performed on the
> unsigned value of pctrl->irq[i] and the check is never true because
> an unsigned cannot be less than zero. Fix this by assinging the
> signed int ret to the return of platform_get_irq and checking ret
> instead.
>
Thanks for spotting!
> Detected by CoverityScan, CID#1470247 ("Unsigned comparison against 0")
>
> Fixes: 6c5d0736e9c0 ("pinctrl: actions: Add interrupt support for OWL S900 SoC")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/pinctrl/actions/pinctrl-owl.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pinctrl/actions/pinctrl-owl.c b/drivers/pinctrl/actions/pinctrl-owl.c
> index 4fa9cc377b3b..133ce9e0000a 100644
> --- a/drivers/pinctrl/actions/pinctrl-owl.c
> +++ b/drivers/pinctrl/actions/pinctrl-owl.c
> @@ -1026,11 +1026,10 @@ int owl_pinctrl_probe(struct platform_device *pdev,
> }
>
> for (i = 0; i < pctrl->num_irq ; i++) {
> - pctrl->irq[i] = platform_get_irq(pdev, i);
> - if (pctrl->irq[i] < 0) {
> - ret = pctrl->irq[i];
> + ret = platform_get_irq(pdev, i);
> + pctrl->irq[i] = ret;
Can we move this statement below if condition:
ret = platform_get_irq(pdev, i);
if (ret < 0)
goto err_exit;
pctrl->irq[i] = ret;
This looks slightly better.
Thanks,
Mani
> + if (ret < 0)
> goto err_exit;
> - }
> }
>
> ret = owl_gpio_init(pctrl);
> --
> 2.17.1
>
WARNING: multiple messages have this Message-ID (diff)
From: manivannan.sadhasivam@linaro.org (Manivannan Sadhasivam)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH][next] pinctrl: actions: fix unsigned less than zero comparison
Date: Mon, 2 Jul 2018 17:59:49 +0530 [thread overview]
Message-ID: <20180702122949.GA9925@mani> (raw)
In-Reply-To: <20180702121504.6731-1-colin.king@canonical.com>
Hi Colin,
On Mon, Jul 02, 2018 at 01:15:04PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The check to see if platform_get_irq failed is performed on the
> unsigned value of pctrl->irq[i] and the check is never true because
> an unsigned cannot be less than zero. Fix this by assinging the
> signed int ret to the return of platform_get_irq and checking ret
> instead.
>
Thanks for spotting!
> Detected by CoverityScan, CID#1470247 ("Unsigned comparison against 0")
>
> Fixes: 6c5d0736e9c0 ("pinctrl: actions: Add interrupt support for OWL S900 SoC")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/pinctrl/actions/pinctrl-owl.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pinctrl/actions/pinctrl-owl.c b/drivers/pinctrl/actions/pinctrl-owl.c
> index 4fa9cc377b3b..133ce9e0000a 100644
> --- a/drivers/pinctrl/actions/pinctrl-owl.c
> +++ b/drivers/pinctrl/actions/pinctrl-owl.c
> @@ -1026,11 +1026,10 @@ int owl_pinctrl_probe(struct platform_device *pdev,
> }
>
> for (i = 0; i < pctrl->num_irq ; i++) {
> - pctrl->irq[i] = platform_get_irq(pdev, i);
> - if (pctrl->irq[i] < 0) {
> - ret = pctrl->irq[i];
> + ret = platform_get_irq(pdev, i);
> + pctrl->irq[i] = ret;
Can we move this statement below if condition:
ret = platform_get_irq(pdev, i);
if (ret < 0)
goto err_exit;
pctrl->irq[i] = ret;
This looks slightly better.
Thanks,
Mani
> + if (ret < 0)
> goto err_exit;
> - }
> }
>
> ret = owl_gpio_init(pctrl);
> --
> 2.17.1
>
next prev parent reply other threads:[~2018-07-02 12:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-02 12:15 [PATCH][next] pinctrl: actions: fix unsigned less than zero comparison Colin King
2018-07-02 12:15 ` Colin King
2018-07-02 12:15 ` Colin King
2018-07-02 12:29 ` Manivannan Sadhasivam [this message]
2018-07-02 12:41 ` Manivannan Sadhasivam
2018-07-02 12:29 ` Manivannan Sadhasivam
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=20180702122949.GA9925@mani \
--to=manivannan.sadhasivam@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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.