Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp503949pxb; Thu, 9 Sep 2021 06:02:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzC7zuZTHRqeN/Zvbgq/wuH5wBH0StcuyC9+XqDy2EvWy4TqjyCzGeN0F2zR6d37LuTlmrC X-Received: by 2002:a02:9695:: with SMTP id w21mr2720635jai.64.1631192566263; Thu, 09 Sep 2021 06:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631192566; cv=none; d=google.com; s=arc-20160816; b=ouFA8Nb+sERU/wKGEmO9BkuxtYNsmwJFtIC6tMZq3OhL7+4c+7tAUg18dGzIHFLqg/ qJcnG7Ki7rdroJ4P2Ql194KywzuNnVZ2eYRm16e3JIme2ikysBCsTS774BP8Pb+LL0cL fpGAeRnRz+WEH1vbS2qDItwPpB630qg4qIW7NAII8C4eeDevq5yi7skUIRqUxwcxRQIe yAu+5rl66A32/1ypfxmr2UG9asndHVamRrRlJjPg/MHs18HiW793waU7N3Pqzgs+ZEvf sje9ZD/mtnGXNXFn9ycbiDyzKhjoqe1eU7fvFrkTvxRD2hWH00C1W0ah17SZUUQC7zLN 2kKQ== 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=pYVyeXtLyBG9wJPlXEtcFQJSOU2ZNwybVW8RTOrJoTI=; b=jOu9lV/NhghazIcgj9Jb88b5ovKU4GfhTjK+Zl75lbeo8qkf/A1s9xWcd3lZyViCDI 5UVdz2v7+9KsjHF/prOk32mTW3mXBDQQZ3fm1m8nABsZzgJi4tbAYK6tQhc/KD/rcUXl jey4YKlrdT3InTHzg+oOx/+bcA4cUh3GJfUU3lHj2L74Izs6hrhyLEPwP33FSsDicInE +1GAgKd38etXlLEWmtegyiRke6o4T1WpVGAu1DdPwkzGd1NPSOgfPGQ8/cd7o1Ih3pTS 9L7vfLMpQ8dkejo9S0iTC2XP6YOiuRcPvkRw7aD56Jub3PiWpL7zR155uMvXIZR/2MoM UyVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QOrTuGPL; 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 d14si1494252jaf.71.2021.09.09.06.02.14; Thu, 09 Sep 2021 06:02:46 -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=QOrTuGPL; 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 S1357054AbhIIM7Y (ORCPT + 99 others); Thu, 9 Sep 2021 08:59:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:60532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353610AbhIIMrE (ORCPT ); Thu, 9 Sep 2021 08:47:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4417C61C13; Thu, 9 Sep 2021 11:56:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188572; bh=6J6zPQmnNKWm5XTWmA6GFpBNcnAP7lr0aUlalCAMhh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QOrTuGPLzlnTWc9MoHsokJCQgJbFd35sqhIo/YA24k0DYbuqOGH8F4kjPcPGU9knW 8FFM1YaHw+5FYSWYyk106PSbJdhJWUmpgEpq5Ih93BTIoDwV9VKJ9LnuUxrb8fzXHX dohnls8JFTGrbZqiijPS2pWNNoDd6P2zTcI0Rr4NXUyKuEzHz3N4WEZ4DTEivywOlW SEnS7lY/duAznqr0wNoOI9GfyUeaGULC0IGIR/zhJFL+NwkbeAposOcRO6npSRy132 dbeNcdEL8Cd5R/Yuu7Rz4ADMyQ8InbnBeC6SJlt1/F8GJf8zVjCfG3ovtoAr7e1DDE 4mI3M2lndepGQ== 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.4 051/109] media: v4l2-dv-timings.c: fix wrong condition in two for-loops Date: Thu, 9 Sep 2021 07:54:08 -0400 Message-Id: <20210909115507.147917-51-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115507.147917-1-sashal@kernel.org> References: <20210909115507.147917-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 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