From patchwork Wed Aug 1 21:55:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 10553101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9FC1C1708 for ; Wed, 1 Aug 2018 21:54:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ED0328825 for ; Wed, 1 Aug 2018 21:54:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8362029492; Wed, 1 Aug 2018 21:54:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71DB928825 for ; Wed, 1 Aug 2018 21:54:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732331AbeHAXma (ORCPT ); Wed, 1 Aug 2018 19:42:30 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:57934 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbeHAXma (ORCPT ); Wed, 1 Aug 2018 19:42:30 -0400 Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 171612D14; Wed, 1 Aug 2018 23:54:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1533160472; bh=TkbZG6suQ+B1Sk3O4dDqq8G0q4m+erpiVLk7D+HliDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=li2iSctARvJze1o9V4WZpbuMNeOfhYsBlqLU4fXuEOzy3MgTAMH7jF7XuBjGkGJOB Ytcg2cwUDNco24AY9M6jbppAQ8rl+bIxpQMl65e5J9NMII0hJpdjl4wJ4XCYMws3l6 zZEIBx4jGqolnC95uxttGcteVL0qrTCqkpSJhjuU= From: Laurent Pinchart To: linux-usb@vger.kernel.org Cc: Felipe Balbi , Joel Pepper , Kieran Bingham , Andrzej Pietrasiewicz Subject: [PATCH v2 8/8] usb: gadget: uvc: configfs: Prevent format changes after linking header Date: Thu, 2 Aug 2018 00:55:05 +0300 Message-Id: <20180801215505.7658-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180801215505.7658-1-laurent.pinchart@ideasonboard.com> References: <20180801215505.7658-1-laurent.pinchart@ideasonboard.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Joel Pepper While checks are in place to avoid attributes and children of a format being manipulated after the format is linked into the streaming header, the linked flag was never actually set, invalidating the protections. Signed-off-by: Joel Pepper Reviewed-by: Kieran Bingham --- drivers/usb/gadget/function/uvc_configfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c index b8763343dcae..799dc32c5bc7 100644 --- a/drivers/usb/gadget/function/uvc_configfs.c +++ b/drivers/usb/gadget/function/uvc_configfs.c @@ -928,6 +928,7 @@ static int uvcg_streaming_header_allow_link(struct config_item *src, format_ptr->fmt = target_fmt; list_add_tail(&format_ptr->entry, &src_hdr->formats); ++src_hdr->num_fmt; + ++target_fmt->linked; out: mutex_unlock(&opts->lock); @@ -965,6 +966,8 @@ static void uvcg_streaming_header_drop_link(struct config_item *src, break; } + --target_fmt->linked; + out: mutex_unlock(&opts->lock); mutex_unlock(su_mutex);