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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 050F7C76186 for ; Wed, 24 Jul 2019 19:44:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CCD35214AF for ; Wed, 24 Jul 2019 19:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997455; bh=iEVO7Mwyc+/zRoAVdOtOLYrlhRjUey94vRhKWeoQyZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=h6SgeO6tha/4Fxlx594nyxIC6Jv//Ve/kkCldbsNEom1T5on5McUHAxFqJBX/xmF3 QmaqCheZFQT8VlDrVRMiu3z4sMa7Hm31ds5Dl32GoBenICiJKKt8VyuKJFjIly+f21 2IycEo5ANYi6Cai0xhiLReYUZe01FoKYh22FCWh8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390779AbfGXToO (ORCPT ); Wed, 24 Jul 2019 15:44:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:46788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390320AbfGXToG (ORCPT ); Wed, 24 Jul 2019 15:44:06 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8221F214AF; Wed, 24 Jul 2019 19:44:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997446; bh=iEVO7Mwyc+/zRoAVdOtOLYrlhRjUey94vRhKWeoQyZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZYvwzu/riL4cnSy4pITpsYXOo0AriGigCYvwpW/wfrUxk0LFFXUcGoLNUUst6JtTB TBXy9aeQUSfLbneeuUjee247/TyJllyut3KBrV+MsIXIEuPz9AdbxZX2XL/cuuGbne B684+8cD9XEwjZkbVtaCkezlzOeGxxnnneW0ymgA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenyou Yang , Eugen Hristev , Akinobu Mita , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.1 026/371] media: ov7740: avoid invalid framesize setting Date: Wed, 24 Jul 2019 21:16:18 +0200 Message-Id: <20190724191726.462702834@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 dfece91ce96b..8207e7cf9923 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