lkml.org 
[lkml]   [2020]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 5.4 374/459] driver core: platform: fix u32 greater or equal to zero comparison
    Date
    From: Colin Ian King <colin.king@canonical.com>

    [ 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 | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/drivers/base/platform.c b/drivers/base/platform.c
    index ee99b15581290..60386a32208ff 100644
    --- a/drivers/base/platform.c
    +++ b/drivers/base/platform.c
    @@ -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);
    --
    2.20.1
    \
     
     \ /
      Last update: 2020-02-14 18:23    [W:5.870 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site