Skip to content

Commit 0707cfa

Browse files
Colin Ian Kinggregkh
authored andcommitted
driver core: platform: fix u32 greater or equal to zero comparison
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: 39cc539 ("driver core: platform: Prevent resouce overflow from causing infinite loops") Signed-off-by: Colin Ian King <[email protected]> Reviewed-by: Rafael J. Wysocki <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f3c1948 commit 0707cfa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/base/platform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ int platform_device_add(struct platform_device *pdev)
571571
pdev->id = PLATFORM_DEVID_AUTO;
572572
}
573573

574-
while (--i >= 0) {
574+
while (i--) {
575575
struct resource *r = &pdev->resource[i];
576576
if (r->parent)
577577
release_resource(r);

0 commit comments

Comments
 (0)