Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4070270pxb; Mon, 8 Feb 2021 07:15:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYlBoCIrtrJDgLXAGKJVs5qtPG+RcvONnzKowXUC817XQqzy8RS96DVBu+u9CQ58yv2ial X-Received: by 2002:a05:6512:a90:: with SMTP id m16mr10186168lfu.577.1612797335291; Mon, 08 Feb 2021 07:15:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612797335; cv=none; d=google.com; s=arc-20160816; b=qPfGUv7bXPx2UqJKBAMk+oYeTt9fAe+X7fAZ/uLC+7gJNIU96YzaXdYGM9mOWf1BNs 9hENqAuOO5zQ+xgaEDXkeKXwuMm5CjcluTtXarX/Qlgp/fKLhVeH/1xGkExpfwl6PjkL D0p7BnAqZKwTGzls0m9MA1n3x0LAuw737+Ind7VimL0Hptnnfw/rEWy2+8VvzAAO3DoB wBPB+bNkutOmLPIu61JGVUsDEHMltTVUXqgQz/LZ4Hc8IL0JvrN6tlFhplCuA8a8urHC HiURfN9L52WALCiqoHfdX+0e146kdCP84NyeEP7j16tuE0h8X0ItpNcpuTi281J7WGaC iTfg== 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=NmPCPy5Lg+rnrPVitbB0Lv+juS8ihiDgSJ+nR0QmMKo=; b=HFF6cI25LdyEswn7fspYvuR/BwZ7/349DeuRg02xoH+e45Bfj/u8XNA0Jx0snWZ7rx CMFNZKOZEryRNNRZAW7xEY/dwFuueu137xA89fi0wPuupo4nfcVsaLCsc05qr9L6UmW2 fh6SovlI7oQRBchc00OLzf8GHXIzld0BVNpCgflb6RNbsCgP+59vK2fxnhVMuhb2XHoZ HvBfq37TKPpeOT/VIumbGaBq4Dt87L3xb2PYOFKXoPLOUhQdHSmczFYo0kkX/GFrW4zY JnmLt+01CxGO2PET7eOuRzvISU4JYiA8nKP1sog7t1pzWyskreEtJMTsXPXbC7o4NMx5 y/rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mVSahTkr; 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=pass (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 e18si11131922ejj.130.2021.02.08.07.15.11; Mon, 08 Feb 2021 07:15:35 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=mVSahTkr; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233355AbhBHPOA (ORCPT + 99 others); Mon, 8 Feb 2021 10:14:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:51778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232693AbhBHPDi (ORCPT ); Mon, 8 Feb 2021 10:03:38 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7529A64EB8; Mon, 8 Feb 2021 15:02:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612796561; bh=uNdtUiPu/JXuxmabfk74niAlwlkvOOeoAi5s2CdvdPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mVSahTkrz+xbUcAEV8JcrkAtNomqLFdpwra0/0IlwyCYuGUWPsVHeWTQ8NAcGJz/a yA3QVlES7BIuAy50EnFEzNRA0brXVwXMIoY8ewwfamk8lO5hU34oZLDZv1Mk4ENrQK nyTtuA7anUG2E6/f8/KpH5DpvmosR8ahF/pD55kw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pete Zaitcev , Jeremy Figgins Subject: [PATCH 4.4 24/38] USB: usblp: dont call usb_set_interface if theres a single alt Date: Mon, 8 Feb 2021 16:00:46 +0100 Message-Id: <20210208145806.232404013@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145805.279815326@linuxfoundation.org> References: <20210208145805.279815326@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: Jeremy Figgins commit d8c6edfa3f4ee0d45d7ce5ef18d1245b78774b9d upstream. Some devices, such as the Winbond Electronics Corp. Virtual Com Port (Vendor=0416, ProdId=5011), lockup when usb_set_interface() or usb_clear_halt() are called. This device has only a single altsetting, so it should not be necessary to call usb_set_interface(). Acked-by: Pete Zaitcev Signed-off-by: Jeremy Figgins Link: https://lore.kernel.org/r/YAy9kJhM/rG8EQXC@watson Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/usblp.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -1349,14 +1349,17 @@ static int usblp_set_protocol(struct usb if (protocol < USBLP_FIRST_PROTOCOL || protocol > USBLP_LAST_PROTOCOL) return -EINVAL; - alts = usblp->protocol[protocol].alt_setting; - if (alts < 0) - return -EINVAL; - r = usb_set_interface(usblp->dev, usblp->ifnum, alts); - if (r < 0) { - printk(KERN_ERR "usblp: can't set desired altsetting %d on interface %d\n", - alts, usblp->ifnum); - return r; + /* Don't unnecessarily set the interface if there's a single alt. */ + if (usblp->intf->num_altsetting > 1) { + alts = usblp->protocol[protocol].alt_setting; + if (alts < 0) + return -EINVAL; + r = usb_set_interface(usblp->dev, usblp->ifnum, alts); + if (r < 0) { + printk(KERN_ERR "usblp: can't set desired altsetting %d on interface %d\n", + alts, usblp->ifnum); + return r; + } } usblp->bidir = (usblp->protocol[protocol].epread != NULL);