mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-21 01:51:18 +00:00
driver core: platform: fix u32 greater or equal to zero comparison
[ Upstream commit0707cfa5c3
] 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:39cc539f90
("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>
This commit is contained in:
parent
843eb0a8cf
commit
f11aefc996
1 changed files with 1 additions and 1 deletions
|
@ -543,7 +543,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);
|
||||
|
|
Loading…
Reference in a new issue