From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Colin King <colin.king@canonical.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Simon Schwartz <kern.simon@theschwartz.xyz>,
kernel-janitors@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][next] driver core: platform: fix u32 greater or equal to zero comparison
Date: Thu, 16 Jan 2020 21:37:16 +0100 [thread overview]
Message-ID: <CAJZ5v0hpn2mdp88B46xaaVPkHSPESadJd3A4ZwijHAW5nOidwg@mail.gmail.com> (raw)
In-Reply-To: <20200116175758.88396-1-colin.king@canonical.com>
On Thu, Jan 16, 2020 at 6:58 PM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the check that a u32 variable i is >= 0 is always true because
> the unsigned variable will never be negative, causing the loop to run
> forever. Fix this by changing the pre-decrement check to a zero check on
> i followed by a decrement of i.
>
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: 39cc539f90d0 ("driver core: platform: Prevent resouce overflow from causing infinite loops")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/base/platform.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 864b53b3d598..7fa654f1288b 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -571,7 +571,7 @@ int platform_device_add(struct platform_device *pdev)
> pdev->id = PLATFORM_DEVID_AUTO;
> }
>
> - while (--i >= 0) {
> + while (i--) {
> struct resource *r = &pdev->resource[i];
> if (r->parent)
> release_resource(r);
> --
> 2.24.0
>
next prev parent reply other threads:[~2020-01-16 20:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-16 17:57 [PATCH][next] driver core: platform: fix u32 greater or equal to zero comparison Colin King
2020-01-16 20:37 ` Rafael J. Wysocki [this message]
2020-01-17 4:42 ` Dan Carpenter
2020-01-17 4:46 ` Dan Carpenter
2020-01-17 5:06 ` Dan Carpenter
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=CAJZ5v0hpn2mdp88B46xaaVPkHSPESadJd3A4ZwijHAW5nOidwg@mail.gmail.com \
--to=rafael@kernel.org \
--cc=colin.king@canonical.com \
--cc=gregkh@linuxfoundation.org \
--cc=kern.simon@theschwartz.xyz \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 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).