Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp449504pxb; Thu, 9 Sep 2021 04:52:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEuOeP+aNs2jc/9SzfJPuSyNcIoSYbJkrK1h+BaschDfjlzdUg3bGSC9lJWhTizmHvNNT2 X-Received: by 2002:a5e:c609:: with SMTP id f9mr2339467iok.127.1631188323424; Thu, 09 Sep 2021 04:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188323; cv=none; d=google.com; s=arc-20160816; b=Rn0qFYA6Y13WVm/IArhBo6xPp0wOoIgJK5mc45QTm1kSBgbzgnuTyRj/AdQm8h3Gwi HWFk5c0UMqcmzH7UQfOf7tr5Ok3t9Q9MGf2oNoIhf71yUaRIDb14Nys9PTCToACixQR0 7jftUpr/UUurO+Oc7gljKb1JUbDa8MFmSJ7RS8fNNtYaEKFzcTO+/khEzh5Dx2spI8IP t6nEASuoUsnL4XOj7W2/Ifm4eqPnocYXeBYN3r61Bj/neU+1JHgfozAYB+Ga1KzSsG4y 1cHKhpx0yla1zJfAcHUrEfV+HkLcFY8HNBzLIz5W8xUj170EX9gNmaH6BHtcy7viZ1VU UOvQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NNCF+p8yJUmOJVTUc8eW+QIPUKsDMjaDJSKNSbu8HZw=; b=z60dn01d3UpyjkVT32Y9TdbS6Y7eMO/6y6KXa+1O2vcGsd6N4fUekSL7ZlV8DEbvVv XyJ8EaYlAW5SzGwoBd/suwMaamgFGPBnPf+Q62EgCrBD8Jkny1pxtlmy4wIDUILu9ycc QaEyLP3OK3Ij5wT1y5Yzz0xmVNf5x+IX2iqGEBjUR7avcTW3VMiKCnbL2gHigz6WDtYr fM4twgNzmd+hz2mA+OEdZSsktIrPpok07H+F50z7nYZvyNEJG9wC1Yidb9nB53+okGA1 dfdIU93N3A3MMjBxHwLrCq3vm5R6a5gd5BWg3AtvF1aeh3wxs9kyT1Jrvbyh9MPhlDMY oMnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PWi01FPL; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m82si1290136ioa.74.2021.09.09.04.51.52; Thu, 09 Sep 2021 04:52:03 -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=@kernel.org header.s=k20201202 header.b=PWi01FPL; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236310AbhIILvX (ORCPT + 99 others); Thu, 9 Sep 2021 07:51:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:54740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242219AbhIILse (ORCPT ); Thu, 9 Sep 2021 07:48:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 115826120D; Thu, 9 Sep 2021 11:43:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187805; bh=kqaF2kdpyKuBuKaT20mI9yFo8DzOL4OTh5ZkI/2DHyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PWi01FPL5iUniKp5ZGawxzXGroSgA75ofqdErL1W7YFjMlFe5lzpHvb+VKphP/ux0 bsXAWxw8IPfAUrxS2cgsvD3zfmDkBUUmgZwjNo0yOhQlWBrmiluz7M/94fO/v9QpLz qVZmAMVC+1Om5E5phKzKl0hfXZHOqusx3pRVfPJVPerVaE3v/C101X91QJqbkVa6F9 jWzsOV2GLCooWyY1lwYfbq2K+38Lj+FUpoBxA59CS/GpNkaz5kbnqgCHwCSqr3FqbE h/CbVFC10L9VUbde+XYUTXt01IQuTdXvexf2F8P/Dd83agNZCfeLzw3OyNm7jrAz+d N2E8Gq70cDKng== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hans Verkuil , =?UTF-8?q?Krzysztof=20Ha=C5=82asa?= , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 108/252] media: v4l2-dv-timings.c: fix wrong condition in two for-loops Date: Thu, 9 Sep 2021 07:38:42 -0400 Message-Id: <20210909114106.141462-108-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore 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