Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1713213pxb; Thu, 16 Sep 2021 13:42:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlCTkfjZCjmBtqP167SF/uHTypNS4fkFMFZpGdlGsFbdIG1icmlh3XQOFdHn/af/YXCslj X-Received: by 2002:aa7:db15:: with SMTP id t21mr8423970eds.229.1631824973541; Thu, 16 Sep 2021 13:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631824973; cv=none; d=google.com; s=arc-20160816; b=rkbGjeDqfDIiqkIyVIM0k+EZoawE7FAjaXIJx18p4YoX14QTTEazmDTP0coBYLHQSl IiOz4/rXJQx6UsvCJCtXmtH/GFM4t+efRL+O+G4cymsBKWAm/tvbOnZ1snDn/q8/pV+3 I45Xso4lJfZrWJiiIMebTbgrK3Rhj/Xq2dP3pLQubwfRLUFmbYBcKMJ+jdJYHqGl+3Nv QAltorSRBv59TuJ03cYNFRmHtJFpJsqFLkOiVllJN1EBK4QMm+rlIdc4/PySYiqiUy8e WeBZZWNrjXNcVzGjV46+37dQbpwq6QiY8aSsR5IaiMEVt/8wAw7rP1gwA4CJNOQKS+sx GgvQ== 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=NNCF+p8yJUmOJVTUc8eW+QIPUKsDMjaDJSKNSbu8HZw=; b=zyrrBLrG+MYPxU42NzRG2/ZHX+Eg/aon5d8rOViqE8RMMRHGQrNSo+6Ghm3y0rgXI4 OiIiWtuEPaCqg9CvRPZBTFo097PvV8AWs4O4XuZ7e60PF1BPd7cWcS/+bzkLgymF2Qli vBJAobTI99PnJYJYmj+hJYT7UFWBbiyisMaPkrTz+Dfn9H4goqeaiZb6yV2iiZHlA1Xh nQuLspPY0ViEZlBjm8MCqpBBVL6VXhdBAMD1BUMbaN7pNA5UcoSBhas48R6Ri8MMAMNL FU+5fHuklOIrc3Yvc3aBOrzte5GguQsqMEq99jyPH0eBZPIiQu2DlzlBTqU+wpOSDAVR FVlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="BPOr/lMv"; 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 k24si4521407edv.610.2021.09.16.13.42.28; Thu, 16 Sep 2021 13:42:53 -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="BPOr/lMv"; 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 S240759AbhIPQZy (ORCPT + 99 others); Thu, 16 Sep 2021 12:25:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:55232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235193AbhIPQSQ (ORCPT ); Thu, 16 Sep 2021 12:18:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E20AD6137B; Thu, 16 Sep 2021 16:12:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808764; bh=kqaF2kdpyKuBuKaT20mI9yFo8DzOL4OTh5ZkI/2DHyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BPOr/lMvHKV2r2UfJoOjrsgRj+sB176h4PW+jep9eJz3U79CWMHaTRjofDhAke4lQ V4bNgSuuWJ1ZnMv4vVwyu0ya980K3Ngd8iFB541TlYipk/pIat+lkraQh3hHsKxjyF MkcEseZ+xHCa20scRfkbKowGFG5pb9GXrGgcElWc= 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.10 181/306] media: v4l2-dv-timings.c: fix wrong condition in two for-loops Date: Thu, 16 Sep 2021 17:58:46 +0200 Message-Id: <20210916155800.251831688@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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 230d65a64217..af48705c704f 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