Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp298828pxx; Wed, 28 Oct 2020 05:19:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb5DZ5BO33snkT3LIden1L7OiZfeS6yEZbdulLUbK+1ZVZ8WM6msHw/ZSyBHFrd2nW3tdd X-Received: by 2002:aa7:d790:: with SMTP id s16mr7558021edq.63.1603887598818; Wed, 28 Oct 2020 05:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603887598; cv=none; d=google.com; s=arc-20160816; b=LRRYmcrV70Dhs28cJTe2FO6Xey1ZfUkD4yXxgMLXLNZOpxmh1Gzm3VtJWqoCJa1mXj 7wUitiztgUsEnLRrBiwVytNWYK1zTasBqn4ikz+BhIAxEhrUf5VAwy3w3hLqBzlIrIxY FDsTYrJRnJUxEHpuzzEgMBv8FD6gO/lQfqxy8H6ZbAN+SOlt+HWmXJIj16uSN+8l3dIG obV/xbk9an01bNrVBCT1LX6OdqR63SoJahPyZYbK57LjpQaSrCjRefuLdZb4WNdMcDJz /1ZkryWg2BdhmdrzeNC4ZcKFJB2bT5evPkIEL/FgvJ/FdZQAw2kUuILaqv1evetHqisM 4hlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=16y1L8ULKb0kPyua6kYTm7nS4FKhzrfFo+HE208hZBc=; b=v6mGFICKXAisLxWweh58HHedCtH8ae9IwYmfDshImELVoCGcptb8cWQU+CYqYj63tM tye0PsLLdMWwhYzePqooBoi5GlNRLlTd6Wrwhx/Z+dobRWiom8VOkIGHN+vvAaSdLW8L UsPoHkoYrUnGTzerOgGJKtUhJ5nLVppdL2i8SJ+UhpJUNcEGboWIxP+g8uTuj31U5G2J GCTvTHU3L71hKZT+rADReGxbLBs7se4PbL+I8HdF2LuohII63MZt19AQj/OI8muAUD2r +3r3HcaLcxi+a4fSNdIHA4wssjIEulwyZ4B9iU3260o0Fn4EstpKN8kCIcORYEOmsVEP 8V6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Lzu0oF6Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk22si2709939edb.258.2020.10.28.05.19.36; Wed, 28 Oct 2020 05:19:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Lzu0oF6Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1796463AbgJ0PSt (ORCPT + 99 others); Tue, 27 Oct 2020 11:18:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:51548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1794941AbgJ0POb (ORCPT ); Tue, 27 Oct 2020 11:14:31 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B2DE120728; Tue, 27 Oct 2020 15:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811670; bh=qAnh+vrLGPL7KCrI1zAkhrziG/CFv+LUFxKOfyozpLw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lzu0oF6YiPWKPhwyM7izkmC43/sEJNCUeQg0vj7KZYEbjNlKY94JYw7JWcqmWJb5Z 9pHLheZD02Qw2P4ThWliJJ80ZpyMxkczBLuFSCuEdIWanH7RbUHkmdaAZxBgkkW3nj aEPqf+UCX+Neq+qraYLxQ69uw5CSMsdNnotyzpas= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Caujolle-Bert , Oliver Neukum , Johan Hovold , Sasha Levin Subject: [PATCH 5.8 575/633] USB: cdc-acm: handle broken union descriptors Date: Tue, 27 Oct 2020 14:55:18 +0100 Message-Id: <20201027135549.779268971@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold [ Upstream commit 960c7339de27c6d6fec13b54880501c3576bb08d ] Handle broken union functional descriptors where the master-interface doesn't exist or where its class is of neither Communication or Data type (as required by the specification) by falling back to "combined-interface" probing. Note that this still allows for handling union descriptors with switched interfaces. This specifically makes the Whistler radio scanners TRX series devices work with the driver without adding further quirks to the device-id table. Reported-by: Daniel Caujolle-Bert Tested-by: Daniel Caujolle-Bert Acked-by: Oliver Neukum Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20200921135951.24045-3-johan@kernel.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/class/cdc-acm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 7499ba118665a..c02488d469185 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -1243,9 +1243,21 @@ static int acm_probe(struct usb_interface *intf, } } } else { + int class = -1; + data_intf_num = union_header->bSlaveInterface0; control_interface = usb_ifnum_to_if(usb_dev, union_header->bMasterInterface0); data_interface = usb_ifnum_to_if(usb_dev, data_intf_num); + + if (control_interface) + class = control_interface->cur_altsetting->desc.bInterfaceClass; + + if (class != USB_CLASS_COMM && class != USB_CLASS_CDC_DATA) { + dev_dbg(&intf->dev, "Broken union descriptor, assuming single interface\n"); + combined_interfaces = 1; + control_interface = data_interface = intf; + goto look_for_collapsed_interface; + } } if (!control_interface || !data_interface) { -- 2.25.1