]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: gspca: Limit frame size to sizeimage.
authorChad Fraleigh <chadf@triularity.org>
Sun, 29 Aug 2021 23:51:27 +0000 (01:51 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 30 Sep 2021 08:07:56 +0000 (10:07 +0200)
Limit frame size to what userland code expects. This can happen when
cameras, such as Kensington VideoCAM, use fixed sized transfer packets
which includes trailing junk in the final packet.

Signed-off-by: Chad Fraleigh <chadf@triularity.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/usb/gspca/gspca.c

index 47d8f28bfdfc2ece0d694279c4b7863685ca061d..770714c34295862052252dfcb650bfe4553df329 100644 (file)
@@ -444,6 +444,8 @@ void gspca_frame_add(struct gspca_dev *gspca_dev,
         * next first packet, wake up the application and advance
         * in the queue */
        if (packet_type == LAST_PACKET) {
+               if (gspca_dev->image_len > gspca_dev->pixfmt.sizeimage)
+                       gspca_dev->image_len = gspca_dev->pixfmt.sizeimage;
                spin_lock_irqsave(&gspca_dev->qlock, flags);
                list_del(&buf->list);
                spin_unlock_irqrestore(&gspca_dev->qlock, flags);