Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10083735ybi; Wed, 24 Jul 2019 15:39:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjSTxmiV1giLMFR6F72aYclOzbGx6oC9hSqudW3WkACi9J3ZpAbXG0J/Tp5xfQiR43C8az X-Received: by 2002:a63:29c4:: with SMTP id p187mr31497553pgp.330.1564007948225; Wed, 24 Jul 2019 15:39:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564007948; cv=none; d=google.com; s=arc-20160816; b=zdS8O/k98wmJR1pLuaAF5+0DNFI2XfIYvi6rvQBioSvMSrgvoMjQqO0c6fLOFQ3nvt TPabdHKctdKKQGET1zMHmvBZy3mtpXxsVVBB9TV1Sm+CD07k1ctxUrQwjkcAnGc/wQrc cQj0GfwkVCt0++hfotIbKo6ShEGy+uMbQTT3VQE2wpuGMV/j9hwQx7Rp7YEp9VSOIHuS TeWhwunPrHJ3MqH0bnycL1Hiw3xFzDtwNt1ATZk+vGy4QwTf0pZSl4/ClqpmAJniBm60 cU+n/cUaLjayshYYbMHKx/lYjnKawNDrDSKuGmxIR10ewkuPxMcH9pYgtpLpFUg9y+Rb EeNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=agNYY866Dpm3NwHOrsDbZqZ0hA5bxJVJUApONlrKptU=; b=OGn8VEXE8Sn3/zFA6bZWc+PE0pJyMHCZ2ZzJEDOHQj+61RJXPIw7PVNS5ksdR88GwY /aIaZ/CgCpFCnjCV7ZqjAUdis51bct5IMup1MFt4S3Ocl4cbByjkzxydVrOzWiX/knq3 P5YIL2dVjMtTEn1K6eohMTMpLhaeG3T/0Hml2XSre2LA+kgZkf59g1GJvG4qBlYARUQJ XaW6iabDbYZ1+hTOcQS6aaZ6FjQc++BKas/fYBT/QXd2mZFtjyOAEOaCLQPK2PR3CsZU X6MoyxV/cmHjKXlJQO7cBrVnQkE9z1NQcq7EOEEISaKPzpsUXTTdtSw3lN+BNVvhU1wI M5IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PxIZMT9E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c8si18893437pje.30.2019.07.24.15.38.53; Wed, 24 Jul 2019 15:39:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PxIZMT9E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387856AbfGXTXn (ORCPT + 99 others); Wed, 24 Jul 2019 15:23:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:39474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387835AbfGXTXk (ORCPT ); Wed, 24 Jul 2019 15:23:40 -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 845DB229ED; Wed, 24 Jul 2019 19:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996219; bh=DW0BB2DTYiRuPIgJVs7ix7BEP9vmGWAvsSoJQnzaCJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PxIZMT9EeimY3KCThwJfPXzxWqzrFNfa2B1yY8EZzS243ml4oH2hT77czEwMZXteM zr2K1v84P1QkH9dT286O2dtgPABe3TwbmSyRGwnzOT0f3d+efGjigLCGDkOdfHl68T DlqNdPlJjoT6fmzyd26RxmX2yvjz1PZzMfAyNR00= 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.2 021/413] media: ov7740: avoid invalid framesize setting Date: Wed, 24 Jul 2019 21:15:12 +0200 Message-Id: <20190724191736.960254327@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 54e80a60aa57..63011d4b4738 100644 --- a/drivers/media/i2c/ov7740.c +++ b/drivers/media/i2c/ov7740.c @@ -785,7 +785,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