Received: by 10.213.65.68 with SMTP id h4csp36320imn; Mon, 19 Mar 2018 18:43:30 -0700 (PDT) X-Google-Smtp-Source: AG47ELt76WD7/b1RhijxeTA0Di1xXqfTivAPLYKg/3IrTXhivOidY365y2mhut8C2u6nVGMSJzSB X-Received: by 2002:a17:902:820a:: with SMTP id x10-v6mr4061268pln.105.1521510210685; Mon, 19 Mar 2018 18:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510210; cv=none; d=google.com; s=arc-20160816; b=wIIy3bGFzrhROSObDgWeY5KmvTarzSXJZpP9Q8ZiXS7w9px8n99iFbpo3ec9OB9Jl9 UKVI+Br4W+B3W+Zr3ukM08SoOTII5vNJRf7hplNg0apI8VK5Q3/eZ8WgNaANGA8MAr2v R59vjcvGhNbc7ezTiSmQO6YamQWWcq2BomXjzh45gzNEUaq6yqK1m2mQAnkoClHjoH0X N4A4HMtCwRW8hc5v0mG3NpHKo1ZitmffikpolmLWyoiunFKjBfnA2Bm2RNzbngjls1iQ iBYEUq2HLRKfSkvT0kooz6PMrTB0hPdxT4Y3rL6vCOUNRkm2Ia+1ecT+0lzzoQ9leGnA BiNA== 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=VI4BUmhRemTmhDgj9ci9ntgrE1OSsc4S/f1v6GZiyKM=; b=ozkrLUjUyrHiNywqYGr+mcz0Gxxf0lfoaG8EPH+6rnc28nllAO9AsC+iNs/x/QpR1J xffd7Do0sB3FvAMHuqug7CRoaowEkwqwL1uFOkPn4zkY+6qZpi+jem3kmpLWlUs8qrLV wtKRaLoIeuN2sj8yMB1HmU5VyaEcduMNOyqvi2Ay3i8bDxqZis8CdXovi/q1NhsAfKyt TcT6249KSLLgEf/7Ht6wbya4vrdb2d+N2We1K4lbF0TcbSG1BM/b45H0nO0EtBPPMWR+ WuBb8kkLrnNriZk+cDwSo8PMD/ekHKXJXQneE6d0b0Ku03emHDu5145U84R5NPJCdJVP 4Wwg== 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 p29si410055pgn.123.2018.03.19.18.43.16; Mon, 19 Mar 2018 18:43:30 -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 S1030822AbeCSSQg (ORCPT + 99 others); Mon, 19 Mar 2018 14:16:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44940 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965963AbeCSSQO (ORCPT ); Mon, 19 Mar 2018 14:16:14 -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 9D85511D5; Mon, 19 Mar 2018 18:16:13 +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.4 100/134] media: cpia2: Fix a couple off by one bugs Date: Mon, 19 Mar 2018 19:06:23 +0100 Message-Id: <20180319171903.684047783@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319171849.024066323@linuxfoundation.org> References: <20180319171849.024066323@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.4-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 @@ -812,7 +812,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; @@ -863,7 +863,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);