Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4094743pxb; Mon, 8 Feb 2021 07:50:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJznlva739xNLb+ci5kZG7APhfLKC+0SZFEEgQE4B8vRIY6w4BHpiNApvQ7yuHlfGVmOSd+J X-Received: by 2002:a05:6402:1484:: with SMTP id e4mr18072061edv.104.1612799429934; Mon, 08 Feb 2021 07:50:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612799429; cv=none; d=google.com; s=arc-20160816; b=tcdZUnfQVI4RMij7PJR4VB4rHIlrpORWt4oiC8a7oMPjHBo/0EI1HHaDHQUFqMZfnm S1papsLAzO8h3QofbGu3wepi95K933mLsrwSy3VdzSHD7S5q2072mTW4eGFhgjX9npkw RIHiQeEQwE2U7ToHxm5qF5hkjwB8NoAlxPpxPJ/g7hOrJERuXLrRlhVMD1d+/YAvQTno 03v5rsnkoDfry3C2dJn+Y3f7ddzJbVUSiZCLLsZ9ZPtH4Zh04X/bR/x7hZVHu3kFAys6 y+hvEMjuBsvS4wZZ3MHYR145tCinex0RECfzqUPoJquSY8BKKZDPd7nG0EhOKMzGu+hm 0X5g== 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=M7sqpE69shUYyaikNVa0GzC7gjikTaONeweXZ5uS8n22NfW73rGiB0a4LNyXwus4HQ HceznBjidJw43S0inqS4rFXYiK9GxUEBR8HGIvNVCcEIKW+MJ9+k8Yty1g1I10dyvapZ UFzVP66Cuev78mgAYT02L9U2YvSvhXtQurji5SRzlrk0qw3UDqPqmKula0fMtvF2hD/8 HcABnWwBh8rjFsIQAFV+Pk4Ewfr5kQMQnDq29/HSvBdpUAKhrEWB7WBxOaWq6s59U38E owAvp9JmraL7zEdlo1MLPkelHncv3HapKMcyS7AdE740TQVwIrRwjCczLzVTL9xv478P NHlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J6HDwnXb; 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 j19si13250476edw.550.2021.02.08.07.50.05; Mon, 08 Feb 2021 07:50:29 -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=J6HDwnXb; 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 S234164AbhBHPsG (ORCPT + 99 others); Mon, 8 Feb 2021 10:48:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:52656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231723AbhBHPHD (ORCPT ); Mon, 8 Feb 2021 10:07:03 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4851864EBD; Mon, 8 Feb 2021 15:05:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612796734; bh=uNdtUiPu/JXuxmabfk74niAlwlkvOOeoAi5s2CdvdPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J6HDwnXba5lTeJEH2aNzHJkyRkmJ5lJ0GrIX+6xIk0WwfGFtJWAyayV0CSOL4uXQb Dc8G0frhMuROYGPUXo8ukUsn5w94HvBFEp+Evsb02egNH3NFpuWpVqCdHrj9B8M0Wn 2rbhUPdx3z284mWVCXuXPmukcRu4KHe4kDn/C04k= 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.9 26/43] USB: usblp: dont call usb_set_interface if theres a single alt Date: Mon, 8 Feb 2021 16:00:52 +0100 Message-Id: <20210208145807.382485465@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145806.281758651@linuxfoundation.org> References: <20210208145806.281758651@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);