Received: by 10.213.65.68 with SMTP id h4csp499645imn; Fri, 16 Mar 2018 09:36:41 -0700 (PDT) X-Google-Smtp-Source: AG47ELtzeqCuDdEaSo4XPvFFcUVrQV76dtBfx7ojGqTITXZ0E3OziCZtXlSXv+8cD0uG5PX5mAk6 X-Received: by 10.98.53.195 with SMTP id c186mr2094354pfa.199.1521218201940; Fri, 16 Mar 2018 09:36:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521218201; cv=none; d=google.com; s=arc-20160816; b=UdM8vp5nlXgyhHY9zZTvk3Jd5E6iO0iWhgzyuz/q3yNUV2B/vqbWZ09ViM7j55nIC2 3KpL3gc8eK9RYhjAVUhAdDAjRmvRHB7fmTVmiUJeCodCG+v8SrbQr7zGVnu5w39BvH/I kxKRDFxht1hdCpHWQ1qlQv709c+VubZQVnTkDqegL88wg8e4z17WSxShOE7o/0lA0TX0 bLKdmOzdWyVgySVkZQG616/tmW9zDAGuOROOTy/SIdmPtEaG7RP+Nzyn/hR/nBMDKglO Y2tYUD26SUJxpVIQGkUzyeFTwqcRypPguFSmjxcpjzJgEu+HrnfwDkrQ9dvzlBOqAee2 LxGA== 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=SG9ES3mrPnG1ObuipzjqDUhdE9xh+fSvEpGlvy/aaSw=; b=P0sq++5Fy+rnZqfmKCbShx1DV/7VMbBl08DU1vD429uwlJaxQhmGNUmAq8Tx9Bp9g+ mK4diUBrxpubhnyfBsAbHFa3OpMpbbRVvNp+gzAQWZIXrA8X1jUs/CZhJ+VbhYIl8VV+ bGxZ5+UZbpbXRKhyLqmESB+6c4JCcYJM3G3ZuSKOiaMmT+wZFVAe7AqWcKwZEUKD+gn9 sWzgb0Zn4lWeDaH8DDjx8SF1mE3C0hiDfl31sqZWUfs1GK3I0I0ehlDKLMyO/vHfuaCJ v7Va7oFl7WchQ5pCtJRrWEwc0UDtMdRYLyNUa4dtqFDWlSF1LYeGvv86eBXPfdLhc+19 V0/Q== 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 x32-v6si6566357pld.591.2018.03.16.09.36.28; Fri, 16 Mar 2018 09:36:41 -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 S1753129AbeCPQen (ORCPT + 99 others); Fri, 16 Mar 2018 12:34:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42062 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934471AbeCPPiC (ORCPT ); Fri, 16 Mar 2018 11:38:02 -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 E52B51260; Fri, 16 Mar 2018 15:37:48 +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.14 087/109] media: cpia2: Fix a couple off by one bugs Date: Fri, 16 Mar 2018 16:23:56 +0100 Message-Id: <20180316152334.668116063@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152329.844663293@linuxfoundation.org> References: <20180316152329.844663293@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.14-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);