diff options
author | Colin Ian King <colin.king@canonical.com> | 2020-01-16 17:57:58 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-02-24 08:34:50 +0100 |
commit | ef728d20156b9272e3673e33599ce3b602838d59 (patch) | |
tree | 96e95c1d6c034f6a53d1a5eba634a8874fff79d0 | |
parent | 149412daa253bd38ac4c213dc2de1ddfb7839d80 (diff) | |
download | linux-stable-ef728d20156b9272e3673e33599ce3b602838d59.tar.gz linux-stable-ef728d20156b9272e3673e33599ce3b602838d59.tar.bz2 linux-stable-ef728d20156b9272e3673e33599ce3b602838d59.zip |
driver core: platform: fix u32 greater or equal to zero comparison
[ Upstream commit 0707cfa5c3ef58effb143db9db6d6e20503f9dec ]
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>
Link: https://lore.kernel.org/r/20200116175758.88396-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/base/platform.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 1d3a50ac2166..d1f901b58f75 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -427,7 +427,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); |