Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2566697lkm; Mon, 20 Sep 2021 18:53:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBm12JW6dwAY2XZI4oJD/vPPOqxF7O3wIQJ6iAc+d9IIWaomr0YPVav3sp6SVMEB/Eb+gW X-Received: by 2002:aa7:c0ca:: with SMTP id j10mr31743516edp.146.1632189223611; Mon, 20 Sep 2021 18:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632189223; cv=none; d=google.com; s=arc-20160816; b=BYbQM/dCwSKBjCCKWxEkqLLLBlouYQbytZp6fImNCszumliij41pO4DNRflDIN5ETj +nQPMdO0JTWnyGDuN0HpmhgCumgJU0O+vo8/R/n4kEwXQizWwaPA4GJyGqLTY+wQ+0Z8 Jox2DeiKUU97o2M8l+0qyc1BOH1nBYEOwEctpF49s5DNEssJKb227CcnhGVKHD9KW0zK UUj9TA45aum8DbD0rB+MtvfU1Hq056WhfHZPsmIW2maWJpXg8v7N4zK0fFV+77umZXKj O4xO6tMhOuvD5ZPo0O048wNzX5ZY7tQsk/XlEn7Nw05a7P7gSePw+F8vr+XCt0inilvK 0t5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pYVyeXtLyBG9wJPlXEtcFQJSOU2ZNwybVW8RTOrJoTI=; b=hsZrczhY4hgzFMDGmqWRso8KDSDAhJgWJ2+2FnU9CR34T6nQhP+w7Thm47+hCGwVtP pK4+7VrNWd3AUbua5EZH2j4kTYrJ7bxu127yW13XX8gkiAMMHTCBfH4QwOybNXY7JUNA qouFUjaSAj2ogU5hbo1xLwA6jLAxNpz9RebltlWlLfdszoSPeXNdvThinX1jfj+LndH1 Da5HWb9UGpmUnkWm8hZCRzkqGYTAlTNDUgUcG4qQgBN7G1aPhn/nHVR1dyazWolH7h9Q +sT3y6dZn4HPXcmy368PdcNnAxWy1Prn9WchEZzZNS4TMPt7JXX0uQFUhjimJ25jWY6d Zrsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v6H5jRiF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si17457066edq.334.2021.09.20.18.53.19; Mon, 20 Sep 2021 18:53:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v6H5jRiF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376987AbhITSQX (ORCPT + 99 others); Mon, 20 Sep 2021 14:16:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:36231 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350743AbhITSKr (ORCPT ); Mon, 20 Sep 2021 14:10:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 69A4D63261; Mon, 20 Sep 2021 17:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158416; bh=6J6zPQmnNKWm5XTWmA6GFpBNcnAP7lr0aUlalCAMhh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v6H5jRiFwVRdBb0gApRtO3WClf8UWjsReVgQ4aWVzRLbclCZq/8wS2uB2w8NMNNTV IcpMnu3wBN/uYMui2L/290JgpeZNYFnxIRPB9fEXYxofVlTMAAioQWuO5RK+YYEjPt YyJv0fNF3zJYWI0BreP7PnrC6slof/Ueqrm8fHeA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans Verkuil , =?UTF-8?q?Krzysztof=20Ha=C5=82asa?= , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 119/260] media: v4l2-dv-timings.c: fix wrong condition in two for-loops Date: Mon, 20 Sep 2021 18:42:17 +0200 Message-Id: <20210920163935.174136646@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans Verkuil [ Upstream commit 4108b3e6db31acc4c68133290bbcc87d4db905c9 ] These for-loops should test against v4l2_dv_timings_presets[i].bt.width, not if i < v4l2_dv_timings_presets[i].bt.width. Luckily nothing ever broke, since the smallest width is still a lot higher than the total number of presets, but it is wrong. The last item in the presets array is all 0, so the for-loop must stop when it reaches that sentinel. Signed-off-by: Hans Verkuil Reported-by: Krzysztof HaƂasa Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/v4l2-core/v4l2-dv-timings.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c index 4f23e939ead0..60454e1b727e 100644 --- a/drivers/media/v4l2-core/v4l2-dv-timings.c +++ b/drivers/media/v4l2-core/v4l2-dv-timings.c @@ -196,7 +196,7 @@ bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t, if (!v4l2_valid_dv_timings(t, cap, fnc, fnc_handle)) return false; - for (i = 0; i < v4l2_dv_timings_presets[i].bt.width; i++) { + for (i = 0; v4l2_dv_timings_presets[i].bt.width; i++) { if (v4l2_valid_dv_timings(v4l2_dv_timings_presets + i, cap, fnc, fnc_handle) && v4l2_match_dv_timings(t, v4l2_dv_timings_presets + i, @@ -218,7 +218,7 @@ bool v4l2_find_dv_timings_cea861_vic(struct v4l2_dv_timings *t, u8 vic) { unsigned int i; - for (i = 0; i < v4l2_dv_timings_presets[i].bt.width; i++) { + for (i = 0; v4l2_dv_timings_presets[i].bt.width; i++) { const struct v4l2_bt_timings *bt = &v4l2_dv_timings_presets[i].bt; -- 2.30.2