]> git.ipfire.org Git - people/arne_f/kernel.git/commit - drivers/base/platform.c
driver core: platform: fix u32 greater or equal to zero comparison
authorColin Ian King <colin.king@canonical.com>
Thu, 16 Jan 2020 17:57:58 +0000 (17:57 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 28 Feb 2020 15:36:06 +0000 (16:36 +0100)
commitcb259e08cb91c893028ea19188e5fae8ea3d9959
tree3dd1565cb10d49f580cb7a0010dced1a88ec980e
parentcf3a133389666d42e79a41095ba4018616f6d186
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>
drivers/base/platform.c