Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp579903pxx; Wed, 28 Oct 2020 11:35:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFH/E8Z1AKv850KZAqQmkcaHLUR8V/6xjJYDS9dx2QmNT/8EzmFzQuhFl6MxN35+HkTz99 X-Received: by 2002:a17:906:6d89:: with SMTP id h9mr437398ejt.152.1603910122542; Wed, 28 Oct 2020 11:35:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603910122; cv=none; d=google.com; s=arc-20160816; b=qz51bpiwxU8Y9ypnAkARfIulbNwyD5sU04bGBSNDwPZXn9RmsS1JHa3pAD99xT66Lj wRNgSRBWvvtrWKKGwWcZHsPALwMQSkCGqzpdF7VKPKQMxNjL1KHvU0fuOS72mZUKOmH6 xtqtl1+2+9vJrybepi87erVYmA3jMTABP5cabE8khb5sVethIRgtsDjgJtKSiVWVpWNL 0iRALHSOjD6CYDC7eX/dCC4QtdKIvFdoJNBIJStncaTkZVvEO54sUe90BRPBFb1Aw8yw V9DpvLDL9Y8UhM4JCQZIQ106roPRBFNkBDUQAJxQ6FSr/tpZKIqXyxPUhTPX58mMqbBm OvLA== 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=bUj0rVEpTrAr0OwHiZ/9v2LE0ctRXbivIXX+SWbNGyM=; b=j7cjKKLiR2+25yjQSU6xnt800JjSJkUphs+vb1EZfRfzZNhILkzb0TgqOL98hbdOPH BcQ3ogx5CyfvU2a8Gh+M07xZyOKFk7w+nOFor87fZjyf0JeYm6t9Gefyi3O/sUsDQ+SV JnH4/WpYffTfUfd4ofCq/NxxEVR440a+wZBIIr3M/QGnP/7wU7liS07Qylas2jqPDB+w y/KHvDzAAEXxF/fyx2lcbyFvkjOfOkMDa/W1ffsH89ur02l1t081i4ZJthUBDmTM7BKc sL6c90bZftGbIOKeXHT7wRwn61J4TFr0LEywOBQ16qA6MDF6FESz0t0jU7zfK3LXlQF4 1kXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="SOX1/gU+"; 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 w23si165eds.571.2020.10.28.11.35.00; Wed, 28 Oct 2020 11:35:22 -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="SOX1/gU+"; 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 S1825207AbgJ0SJk (ORCPT + 99 others); Tue, 27 Oct 2020 14:09:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:37202 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754474AbgJ0OPW (ORCPT ); Tue, 27 Oct 2020 10:15:22 -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 17F5E2072D; Tue, 27 Oct 2020 14:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808122; bh=HSkTCzjmdJyA7OXQ8tGRRk3omSoEe9SMqbiUxADL9aw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SOX1/gU+upkSxrzRLAK7MvLksGjTzzFr9Uum/oD1kFTbZ0yBoT8J2fZwO+el3huPd l3jaZNlYecBKsgFXXE2NRcg+OpH1+1mrIf4HOIN53UdZJj20BClr1OF/eONozI6WtH D5Vg7cyJAF4fV4rLMvm/n+Gpta9t0G29jWJEZJ4E= 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 4.14 164/191] USB: cdc-acm: handle broken union descriptors Date: Tue, 27 Oct 2020 14:50:19 +0100 Message-Id: <20201027134917.611618996@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134909.701581493@linuxfoundation.org> References: <20201027134909.701581493@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 b3e4b014a1cc0..dff9860213624 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -1287,9 +1287,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