Received: by 10.213.65.68 with SMTP id h4csp475914imn; Fri, 16 Mar 2018 08:55:11 -0700 (PDT) X-Google-Smtp-Source: AG47ELs6y5FA641dCYl+b13mWbxgyagQhuie0tafC2SYeUCHiqoMBnA9kqUVkdCsoM+Xa/CUQd1o X-Received: by 10.98.109.131 with SMTP id i125mr1986543pfc.226.1521215711403; Fri, 16 Mar 2018 08:55:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521215711; cv=none; d=google.com; s=arc-20160816; b=JWo2UqAJq3qVPNSopYpYIF7aY8GwXleXVs4WxtozTqktNUqAYrReRj3uSWD/GZNV0u 6aixGpvnO7pAskQTK7M5p37+ak2wCc/D9znsH5Ct+CunnG3ZaGJ1hdQZP7HqznHKqtlt 57CkxMXPbHZsqbBqcAYOYaDBSkG3t54OBDps9cCK9cjTf7gbgfXuxmq6mrPGga7ldTNT Pwq87NQUmjC7pETKVI3ZPNbIXbR73Lea560By4mijYcQkrJ/FoVKI+IAMyK7yLlvybfQ fg7I85qtK5tnQFa21G6ziqpf/sV21GbgKfPci7wo8JsDPWljaiaj+q9GjzECnxXu6TuN l9eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=z6h48zBYFo0JM6Nm5AykO7nGMYOdh1FYtgOdECDa1fI=; b=BbgPE4J2STwF4EJ142HYfP5S/z8Mf1ea9jI6B/qNnGjT6lFBhZIm7R17z8B5J0mAwB bONiZLrIZ3oPoiPLPH+/SsmMc8kqV77F0Mb2gV65X8MnEwfqdNP0HFvlS2euwSE6v8N/ evWc0T6OWEC0KlLaXbLOJs6UvX1UG2r0idInzqOfXMIyFJhLDJKahtQbeMZj2lQmTBvq 4cSypmZmuwJVDf3d9YdGAE46bjYeLYMOucekhoTY2JCqBNUTpEpz03Ensse2NHQEN/0I eQL6Ky5I5h1wblHwbsx5zMoTadY7HNos7qa4DlovVS/zvvyqO8OLSslPpZDNxJ3X3+gg GFfQ== ARC-Authentication-Results: i=1; mx.google.com; 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 v15si5208982pgt.635.2018.03.16.08.54.56; Fri, 16 Mar 2018 08:55:11 -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; 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 S965359AbeCPPoH (ORCPT + 99 others); Fri, 16 Mar 2018 11:44:07 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45806 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754920AbeCPPoD (ORCPT ); Fri, 16 Mar 2018 11:44:03 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8F6FDDA8; Fri, 16 Mar 2018 15:44:02 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.15 106/128] media: cpia2: Fix a couple off by one bugs Date: Fri, 16 Mar 2018 16:24:07 +0100 Message-Id: <20180316152341.835630330@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit d5ac225c7d64c9c3ef821239edc035634e594ec9 ] The cam->buffers[] array has cam->num_frames elements so the > needs to be changed to >= to avoid going beyond the end of the array. The ->buffers[] array is allocated in cpia2_allocate_buffers() if you want to confirm. Fixes: ab33d5071de7 ("V4L/DVB (3376): Add cpia2 camera support") Signed-off-by: Dan Carpenter Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/cpia2/cpia2_v4l.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/media/usb/cpia2/cpia2_v4l.c +++ b/drivers/media/usb/cpia2/cpia2_v4l.c @@ -808,7 +808,7 @@ static int cpia2_querybuf(struct file *f struct camera_data *cam = video_drvdata(file); if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || - buf->index > cam->num_frames) + buf->index >= cam->num_frames) return -EINVAL; buf->m.offset = cam->buffers[buf->index].data - cam->frame_buffer; @@ -859,7 +859,7 @@ static int cpia2_qbuf(struct file *file, if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || buf->memory != V4L2_MEMORY_MMAP || - buf->index > cam->num_frames) + buf->index >= cam->num_frames) return -EINVAL; DBG("QBUF #%d\n", buf->index);