Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4663219rwb; Tue, 20 Sep 2022 18:09:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7U56ov5cQOnZkBmKvifBHQ0qgbrHlRn8Yy50YYkaOgFxs3fUbHHAd8uvy0NkA2if3afCsN X-Received: by 2002:a63:d250:0:b0:435:1774:1f93 with SMTP id t16-20020a63d250000000b0043517741f93mr22660045pgi.339.1663722590756; Tue, 20 Sep 2022 18:09:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663722590; cv=none; d=google.com; s=arc-20160816; b=TZ7Ei/e8TgkaxwUHYHvx1QDxqhWK367eqIDHDLLtXEnaTYcdbRSj5SH8mbM/NO7UrF e9fI65v6LW7NlcK9R1t3c/ctv2kn7sx7w3bPrjd7dTmdpFGtywMzT3cqkoHUoEjykVQv KNkjnSiJEDChtbb+sd4lh+5t7evkpRhq4c+Mu6570BRxeiEBxZ6hcM9BN8bBN6VbFhuD q4rW2eZQG0E9J0Yk9t+rpMwlG4H108O9ygyauY/iZoG+KfPNYv149dq2wlWizxTQA570 Z8DVAIvOEQh4lcTJQYLne6+Hike7pjn+LgCnFMLUwCQypVAHJHzfCyRb4zhqHEs6Ne3h 0cIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=L5iOgOj6W8YclqxWGqOqlqqNFTlupAOCo4vVXoP1Lgk=; b=KrZjtKjfjSqkna1jHWrp1zXZwar+UJ47XN9ZvTElis+FtUBufzeD4EdTp2opdnqKIH dz9Y9R9BkhH7wjM+BkQwvqwcuBPBR6z7cHvMNnyPFN/dT2ika99X32VyXxGwvOcDD3ej kTJpn7HFZxX8aeY61xVGPZt5Oni09VeS8pZLIwWYFfuRsrh6ocMy3RwOrUFNqS1UPmh9 ABWg4CSWyNgSpGYzoKIS52MobMHuAf0md4ouw/Odhu6/C32YVcZ2dC5VoEOt3k57o3Qz QVXYOVokpaKZSNXGwhMBvOWaky2/ICuYIIx9JtrZmv3a2RSsdZ0CazmG0Ug/4fUTkS6P UK0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=blZQMaVf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x185-20020a6263c2000000b0053e989053f9si1230945pfb.114.2022.09.20.18.09.39; Tue, 20 Sep 2022 18:09:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=blZQMaVf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231259AbiIUAx5 (ORCPT + 99 others); Tue, 20 Sep 2022 20:53:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230419AbiIUAxw (ORCPT ); Tue, 20 Sep 2022 20:53:52 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E23B79A78; Tue, 20 Sep 2022 17:53:51 -0700 (PDT) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 11D76415; Wed, 21 Sep 2022 02:53:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1663721626; bh=NKIBgvf5EtOAYU3QLWV5VyxZpPJqOS7yx89s5sYlf5U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=blZQMaVfVNLDa8/2YPRtCI2NTuYDjtw7wWUSk53LSLafVL+bdwF3IKdvzsQCLxVjH YZwU+N+JJJFfjx5+t0j4vSnuQQoza3kRv3jW4u+4MKsV0eB1kxhs+5ZDlhhXilYBAp 9RAsNZKa0rASQSZ4tNPsxPmk1zEVY4oxB1+aQN2w= Date: Wed, 21 Sep 2022 03:53:31 +0300 From: Laurent Pinchart To: Ricardo Ribalda Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot Subject: Re: [PATCH v1 1/1] media: uvc: Handle cameras with invalid descriptors Message-ID: References: <20220920-invalid-desc-v1-0-76a93174f3bc@chromium.org> <20220920-invalid-desc-v1-1-76a93174f3bc@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220920-invalid-desc-v1-1-76a93174f3bc@chromium.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ricardo, Thank you for the patch. On Tue, Sep 20, 2022 at 04:04:55PM +0200, Ricardo Ribalda wrote: > If the source entity does not contain any pads, do not create a link. > > Reported-by: syzbot > Signed-off-by: Ricardo Ribalda > > diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c > index 7c4d2f93d351..1f730cb72e58 100644 > --- a/drivers/media/usb/uvc/uvc_entity.c > +++ b/drivers/media/usb/uvc/uvc_entity.c > @@ -43,7 +43,7 @@ static int uvc_mc_create_links(struct uvc_video_chain *chain, > source = (UVC_ENTITY_TYPE(remote) == UVC_TT_STREAMING) > ? (remote->vdev ? &remote->vdev->entity : NULL) > : &remote->subdev.entity; > - if (source == NULL) > + if (source == NULL || source->num_pads == 0) source->num_pads and remote->num_pads should always be identical, but as the next line uses remote->num_pads, wouldn't it be better to test that variable ? If so, I'd move the test a file lines earlier, with the remote == NULL test. What do you think ? If you agree I can make that change when applying, there's no need for a new version. Otherwise I'll keep the patch as-is. > continue; > > remote_pad = remote->num_pads - 1; > -- Regards, Laurent Pinchart