[media] vb2: fix plane index sanity check in vb2_plane_cookie()
authorZhaowei Yuan <zhaowei.yuan@samsung.com>
Fri, 22 Aug 2014 02:28:21 +0000 (23:28 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Sun, 21 Sep 2014 23:50:21 +0000 (20:50 -0300)
It's also invalid when plane_no is equal to vb->num_planes

Signed-off-by: Zhaowei Yuan <zhaowei.yuan@samsung.com>
Cc: stable@vger.kernel.org # for v3.7 and up
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/v4l2-core/videobuf2-core.c

index 7f70fd521ab1e8a3277376ee704402b360fa0800..c2126d87454961c03c5fcdbe3b0001bf790e8af1 100644 (file)
@@ -1130,7 +1130,7 @@ EXPORT_SYMBOL_GPL(vb2_plane_vaddr);
  */
 void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no)
 {
-       if (plane_no > vb->num_planes || !vb->planes[plane_no].mem_priv)
+       if (plane_no >= vb->num_planes || !vb->planes[plane_no].mem_priv)
                return NULL;
 
        return call_ptr_memop(vb, cookie, vb->planes[plane_no].mem_priv);