media: uvcvideo: Handle cameras with invalid descriptors
authorRicardo Ribalda <ribalda@chromium.org>
Tue, 20 Sep 2022 14:04:55 +0000 (16:04 +0200)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Sun, 15 Jan 2023 21:45:08 +0000 (23:45 +0200)
If the source entity does not contain any pads, do not create a link.

Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
drivers/media/usb/uvc/uvc_entity.c

index 7c4d2f93d351373cd70ce47c774ef5501ba933d7..cc68dd24eb42dce5b2846ca52a8dfa499c8aed96 100644 (file)
@@ -37,7 +37,7 @@ static int uvc_mc_create_links(struct uvc_video_chain *chain,
                        continue;
 
                remote = uvc_entity_by_id(chain->dev, entity->baSourceID[i]);
-               if (remote == NULL)
+               if (remote == NULL || remote->num_pads == 0)
                        return -EINVAL;
 
                source = (UVC_ENTITY_TYPE(remote) == UVC_TT_STREAMING)