Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1939557ybv; Fri, 14 Feb 2020 08:33:52 -0800 (PST) X-Google-Smtp-Source: APXvYqyoK2yzP4l8rb5v5h596Aq5sPiu+215VhcbRNQe+xgSlGZUxdQh7nHRgbSrJGJ24Kjs5bXV X-Received: by 2002:a9d:2028:: with SMTP id n37mr3104269ota.127.1581698032673; Fri, 14 Feb 2020 08:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581698032; cv=none; d=google.com; s=arc-20160816; b=pXwe0tV5dO3tH/kxtpYYUXXyqAckPazVJKY5krUShN9if1QLCAbhZBw+uHy07qI0X+ Ini2OnDPjYneG8VW5MoBwJdcmVkfxM5fXT5KDD4VUe/e3DZN+x9UlUOvQ9nnGLHwCIqy Upajf4mDnURwAgOeeSP6KPW4vXEfMg4K+9AiKaotVHhZh2o5SgTzDGwgok7IA+Xd/5hp J+TMnDUJkflBDduJPmAD//J8qY8st8mC8JuPXfzw+p7lAmdUhs0fbnCJknZuC7C0cq57 AoMGGtTGulrgAZiEO8zPUFH4+BZbSqFSWml+8BpWjwd4+yUFxYQHO9/WySHYrdf/VOJu Gh5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yrH3u3NbAT6ekVnfEAX2/PHnAlcPS2OdfNa4lQZSExw=; b=0xvS9YJLHdVASryaSBnHQQqbaVbeglzEdMoA7xW4b95gEiCrufIgPJQ79AZ70hM5Gu hmztE2YuM0PGZijj1fGoN2qhoKKcT9uXVffnxoDLZJ6kEmYoZsnLnC6vYVufsg84lC3M v7QVnYp1Y8FYeiYaIpZjIKtg/gW2uAkdB6SShU+BrLtQ+MY98XfhPgHz/eihUyAtUmeB K7xBhxOorTZxwN8SL1rD08iR4xuf0t7IVi4FwSzaJlN8k/6KBXzFsAakKZVx335dsRSV VblboCkAA66+Fqnhgnyxx7bKvOtR78i6icd9kdu3yyztjSWhC89149rT5alhBR7o+xJ5 M4pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KBgVGRYw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s21si3507897otr.304.2020.02.14.08.33.40; Fri, 14 Feb 2020 08:33:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KBgVGRYw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406226AbgBNQZu (ORCPT + 99 others); Fri, 14 Feb 2020 11:25:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:60228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392933AbgBNQXn (ORCPT ); Fri, 14 Feb 2020 11:23:43 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2C34024779; Fri, 14 Feb 2020 16:23:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697422; bh=boCaJ9AjUkm8HQ1bECcY0cYl3TSL6GThXcOQvvRZlhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KBgVGRYwZokQh18N+CDrt8QS6QqIKmFxFkuUcsV2sF/5s2W3YAWLShu4FANU12E7F PVVQBaa1nf8QJz+t4k1MuZVKnZlZbhL6yiVQKXdUPRBSfwEvSw9VVWkm5k0KY8T3K4 XTWkp7+xX/1XGeTzqA+PzIKiHqTikaehJ9QjGtW4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Colin Ian King , "Rafael J . Wysocki" , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.9 112/141] driver core: platform: fix u32 greater or equal to zero comparison Date: Fri, 14 Feb 2020 11:20:52 -0500 Message-Id: <20200214162122.19794-112-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ 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 Reviewed-by: Rafael J. Wysocki Link: https://lore.kernel.org/r/20200116175758.88396-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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 6cdc198965f5a..bef299ef62276 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -418,7 +418,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