From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F58EC76191 for ; Mon, 15 Jul 2019 13:40:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5EFAC2080A for ; Mon, 15 Jul 2019 13:40:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563198038; bh=HE6ERcQjIe0JLOZKqju78rK1r/f4JuYXJmjufqB2V4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ZGm7Cplxe9c5v+lp+hwuZXdWx3SL+7Zye2Fhf6tRnGMsgJChSlkpwKKYtUoHbNRWb a+CW/oJTVDoQvpo2jS/6MRjVzQoVIVTBulOxOsnVqztYidYMpKna8qyHbtUaJE2sH+ VQb9eI/X1fhyjDWbfhEUbL0hwNqsWBPxg97/aOMM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730776AbfGONkh (ORCPT ); Mon, 15 Jul 2019 09:40:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:41694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730589AbfGONkF (ORCPT ); Mon, 15 Jul 2019 09:40:05 -0400 Received: from sasha-vm.mshome.net (unknown [73.61.17.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5D9012086C; Mon, 15 Jul 2019 13:40:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563198004; bh=HE6ERcQjIe0JLOZKqju78rK1r/f4JuYXJmjufqB2V4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HL2dFePtzwiR8U5R6b0jjgMkbLdxkIdpVW6s/KcRpnRCmpt8GQ2vKkFwRjhUXQzdn wd7sycjtojpaXWG2x4YEeaj0E2Bx3zfw+8MYvvVnELGVu9/cKqYCmAeHDSlwA8lMvj AF2eGkppT29JRb7uuP8mtf4poHeJ/P6mZ+A24IUo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Akinobu Mita , Wenyou Yang , Eugen Hristev , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 014/158] media: ov7740: avoid invalid framesize setting Date: Mon, 15 Jul 2019 09:36:59 -0400 Message-Id: <20190715133923.2890-14-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190715133923.2890-1-sashal@kernel.org> References: <20190715133923.2890-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Akinobu Mita [ Upstream commit 6e4ab830ac6d6a0d7cd7f87dc5d6536369bf24a8 ] If the requested framesize by VIDIOC_SUBDEV_S_FMT is larger than supported framesizes, it causes an out of bounds array access and the resulting framesize is unexpected. Avoid out of bounds array access and select the default framesize. Cc: Wenyou Yang Cc: Eugen Hristev Signed-off-by: Akinobu Mita Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/i2c/ov7740.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov7740.c b/drivers/media/i2c/ov7740.c index f5a1ee90a6c5..8a6a7a5929aa 100644 --- a/drivers/media/i2c/ov7740.c +++ b/drivers/media/i2c/ov7740.c @@ -761,7 +761,11 @@ static int ov7740_try_fmt_internal(struct v4l2_subdev *sd, fsize++; } - + if (i >= ARRAY_SIZE(ov7740_framesizes)) { + fsize = &ov7740_framesizes[0]; + fmt->width = fsize->width; + fmt->height = fsize->height; + } if (ret_frmsize != NULL) *ret_frmsize = fsize; -- 2.20.1