]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: uvcvideo: Handle cameras with invalid descriptors
authorRicardo Ribalda <ribalda@chromium.org>
Tue, 20 Sep 2022 14:04:55 +0000 (16:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 15:32:00 +0000 (16:32 +0100)
[ Upstream commit 41ddb251c68ac75c101d3a50a68c4629c9055e4c ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/usb/uvc/uvc_entity.c

index f2457953f27c60454b95c72d460214988f27b50b..0d5aaaa7e2d96d22e32006c7ba417287017a024b 100644 (file)
@@ -42,7 +42,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)