Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp518585pxb; Thu, 9 Sep 2021 06:18:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqq1uDg+7/VPZMHOfuAu5zIq4r4EOk+L0g8ktRvyXBTgKhIZZ+IJWcDmhl7845bWqQihTr X-Received: by 2002:a02:94e4:: with SMTP id x91mr2798673jah.99.1631193496188; Thu, 09 Sep 2021 06:18:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631193496; cv=none; d=google.com; s=arc-20160816; b=JtKpUd7dBVEbk0D/MQ8Jsva7X+1iFA4IQu7dKqf06oZOHIjFTASCEipEvE+5Rq16Ps mdH3I60DbH0rZ+DCRMsNeWW9iRD+0LXeVvT3ZD5PViuobaUCsHDRocnkICBE0GYaH2wY dexYUIIepJ7M+qXZS8XhH+wJQOy0PN9Z9huhbiXAbdiV9eWp+pub9NVwmENu3UpLNoRJ sZwZGxsVVNLkF6YP0nchPBw3y4FHuInqN7PkNj3Rtv70u1LvcFWPBM9lOldJYYfn30iZ sR9XQ/7CdS4lJbC8zneIUqE5zoY/0O8dIgtvQEu9FsM+slHL7ESyMEuVQCoKrhNT7Ec/ bPsA== 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=RPF3+qrEQjNu2JOJndmtw+QkKgwUEJaxemzNr5xsozo=; b=tOoTQM9JAHiA3YzG3s+eyLFlOBkbe7aeeXg5NZP83iAQQPmh2cK3RtDP8t2uRD1EVa xML70bFBe0AmvNk2tPw4MRNapLsVUt5cxkDJnCA7bmuc8ptpCAgdQkzL1F5c+75q/Kem YtrUftHhf1KM7kOfWIZzFDzJyUk4MxPSyxFXmDq36TZ1PZzzryFGqaZ5WmzkYbKP7VZj 5eBpXeHU8N4CPyFoHS+KpaNh8sGfwCuEwBivwsOuMXb4fIpHCoWhHOnUfdxMq+y2xH1g 7l+i/Vqq8WEZrdPg5s8WBt/SKhQ9UlIBWVdwqW5KM1IyX3dW+Mv6sURHkFHthYn/JiPG QLew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cLBbt24t; 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 186si1619873jaf.38.2021.09.09.06.18.03; Thu, 09 Sep 2021 06:18:16 -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=cLBbt24t; 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 S1359121AbhIINQS (ORCPT + 99 others); Thu, 9 Sep 2021 09:16:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:42430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357661AbhIINDP (ORCPT ); Thu, 9 Sep 2021 09:03:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A2E863290; Thu, 9 Sep 2021 11:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188781; bh=bE1/ceCmSk5TxgkKSMKH0vSutzfDglqzezrJJU+M4jA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cLBbt24tehudwv2g3cNHAjIJQJKPPbUME4tMSpRcnRv5FqsL3OGY0HszqnXobXZ+u ir3hsbYy2P6O+D+XSQuiV8XEmjHiO2k95LPNOus40LGr+vQKHspG6gOUfhcRv3pkx8 dE3SF/jJ23zh99kVfnxfae1EbIi0z0aCSdQW4+NQ6QMb0JE16ephjGY32ls0XkIgFN NNVFvMnbtO3F05PYlno5UB0VR483xhPkxonIWcB4Q7f8OwfTLxPSeeYSYk18eDNwqC lKmGmVKxRhKn+eL4qCHMCeoeHAQ2YRJqFV9TvaJzIWlpDMCouEz4eH06bd1zHiPrV3 zR2MKpCp/gDcg== 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 4.14 32/59] media: v4l2-dv-timings.c: fix wrong condition in two for-loops Date: Thu, 9 Sep 2021 07:58:33 -0400 Message-Id: <20210909115900.149795-32-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115900.149795-1-sashal@kernel.org> References: <20210909115900.149795-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 5c8c49d240d1..bed6b7db43f5 100644 --- a/drivers/media/v4l2-core/v4l2-dv-timings.c +++ b/drivers/media/v4l2-core/v4l2-dv-timings.c @@ -207,7 +207,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, @@ -229,7 +229,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