From patchwork Tue Dec 10 11:25:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 11281913 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67F67112B for ; Tue, 10 Dec 2019 11:26:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4681420838 for ; Tue, 10 Dec 2019 11:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575977186; bh=5+oy5P1wK2L2wBlr8oDmrN4Al/6JLnztD1oWXvA+aXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OGM2QxGP3SKTdsmHAnjVy+VIl3AjFgJUK3uFvqSxYzOF+QmmyRy90235yZs0JV17U ICJsXc5MV3nBMs75e6cNIW0hhyORFdcBdeWPvQ0yGswWQFKC4Qey862U9JB7b+85FG v3hOX/KR+2reWIVLAbeSni8Xfki6xRKrPKqJxJIQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727299AbfLJL0W (ORCPT ); Tue, 10 Dec 2019 06:26:22 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:46963 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727114AbfLJL0W (ORCPT ); Tue, 10 Dec 2019 06:26:22 -0500 Received: by mail-lj1-f195.google.com with SMTP id z17so19383448ljk.13; Tue, 10 Dec 2019 03:26:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VoeC8Gum0YS8PrWDUBi3I1lnOTW9TGly1+knOIyyCDI=; b=ti7O1+BetZ4wb1iNJcT+LhATZ56UsFhvPY9rOxTyFWbkKCHdar4f8rvWvVOTiPQH0f Cx1Xoye96Rz92POf/POuHrMZOoCUJ0HfiwodSRlXNspsrhFBDPkRhVVXnIx1L9/U/JEc eZPshCkeQgbLScgTTgbJlv143tJkY3z7ms7V3rXKziwtkN9k1iKs5QkRySou/054qGFS qALvntZYGgsPruhjsJwVcIo6Gy4zYm26oKzqNwYlJv/192f/V3n+jtc17wGlznsc0HDz cNQUo9uzckTAABl7FGdjBIeWraK1bCNpUmPDMmfwzsg9pUjcWUwRZVrD+HHYGDPEbXuA Tv4Q== X-Gm-Message-State: APjAAAUR0405Eqt5Mb4kmQL8CDcPHsd2Nk7Z0FqgZOY1te8syXZN9yRE Ec85+lU37KcA24PiPBvSrr4= X-Google-Smtp-Source: APXvYqxIZw+r35NZC4Ca+7QkhDj+4fd5AfViu2/GZkiwjfQ/1roh+yJ8+HobjDos1Jul3JCIOYX1Sw== X-Received: by 2002:a2e:9143:: with SMTP id q3mr20677028ljg.199.1575977179623; Tue, 10 Dec 2019 03:26:19 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id s7sm1576813ljo.43.2019.12.10.03.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 03:26:18 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1iedem-0000wH-KQ; Tue, 10 Dec 2019 12:26:20 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, Johan Hovold , stable Subject: [PATCH 1/4] USB: atm: ueagle-atm: add missing endpoint check Date: Tue, 10 Dec 2019 12:25:58 +0100 Message-Id: <20191210112601.3561-2-johan@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191210112601.3561-1-johan@kernel.org> References: <20191210112601.3561-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Make sure that the interrupt interface has an endpoint before trying to access its endpoint descriptors to avoid dereferencing a NULL pointer. The driver binds to the interrupt interface with interface number 0, but must not assume that this interface or its current alternate setting are the first entries in the corresponding configuration arrays. Fixes: b72458a80c75 ("[PATCH] USB: Eagle and ADI 930 usb adsl modem driver") Cc: stable # 2.6.16 Signed-off-by: Johan Hovold --- drivers/usb/atm/ueagle-atm.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index 8b0ea8c70d73..635cf0466b59 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c @@ -2124,10 +2124,11 @@ static void uea_intr(struct urb *urb) /* * Start the modem : init the data and start kernel thread */ -static int uea_boot(struct uea_softc *sc) +static int uea_boot(struct uea_softc *sc, struct usb_interface *intf) { - int ret, size; struct intr_pkt *intr; + int ret = -ENOMEM; + int size; uea_enters(INS_TO_USBDEV(sc)); @@ -2152,6 +2153,11 @@ static int uea_boot(struct uea_softc *sc) if (UEA_CHIP_VERSION(sc) == ADI930) load_XILINX_firmware(sc); + if (intf->cur_altsetting->desc.bNumEndpoints < 1) { + ret = -ENODEV; + goto err0; + } + intr = kmalloc(size, GFP_KERNEL); if (!intr) goto err0; @@ -2163,8 +2169,7 @@ static int uea_boot(struct uea_softc *sc) usb_fill_int_urb(sc->urb_int, sc->usb_dev, usb_rcvintpipe(sc->usb_dev, UEA_INTR_PIPE), intr, size, uea_intr, sc, - sc->usb_dev->actconfig->interface[0]->altsetting[0]. - endpoint[0].desc.bInterval); + intf->cur_altsetting->endpoint[0].desc.bInterval); ret = usb_submit_urb(sc->urb_int, GFP_KERNEL); if (ret < 0) { @@ -2179,6 +2184,7 @@ static int uea_boot(struct uea_softc *sc) sc->kthread = kthread_create(uea_kthread, sc, "ueagle-atm"); if (IS_ERR(sc->kthread)) { uea_err(INS_TO_USBDEV(sc), "failed to create thread\n"); + ret = PTR_ERR(sc->kthread); goto err2; } @@ -2193,7 +2199,7 @@ static int uea_boot(struct uea_softc *sc) kfree(intr); err0: uea_leaves(INS_TO_USBDEV(sc)); - return -ENOMEM; + return ret; } /* @@ -2548,7 +2554,7 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, } } - ret = uea_boot(sc); + ret = uea_boot(sc, intf); if (ret < 0) goto error; From patchwork Tue Dec 10 11:25:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 11281907 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E5269112B for ; Tue, 10 Dec 2019 11:26:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B952C2073B for ; Tue, 10 Dec 2019 11:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575977184; bh=uKNEfW0ZWuy1IZOmRCQD1CCOVZM6KypzJ/XWpCNMGDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Vn/tXmQTmJCE4sckhRGPI5ckjPwdKqPkGB6tP8ZGcRwv33Ep8ewo4pHnG4R7MB5Tb nBnv0+xjQ3YI9cYDEQL+2TxnAivX56MZuST7H+MO54UoxqGuEpEX7ordWjpXhSUimt 9qB4dMxMvvKK4XjdCGklopLt3l9i+XPglioT7Ako= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727310AbfLJL0W (ORCPT ); Tue, 10 Dec 2019 06:26:22 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:36262 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727196AbfLJL0W (ORCPT ); Tue, 10 Dec 2019 06:26:22 -0500 Received: by mail-lj1-f194.google.com with SMTP id r19so19474444ljg.3; Tue, 10 Dec 2019 03:26:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WucoAdQqWyBkNs0JJK7CZWsBgKNZr9bbzVbrw8HFiTo=; b=FKzRcbnT9u3OQvLftwa2lflSjWPCqrSn0zVmZOWtfP7JM+TZ4NEEvX7Qv35WB8R6tN XlrBBQtWlmPH3JtL/9zJUmdEYzUlcGU6+34NXNYIvM6r17zT8/DxcFP5yffi9e8CHBZe zs/SyGJhQStRrcyNJSssTJvHZ+Cg0+/UH/niefSHjB4bHAQ3Jyg4ei7CrkmUt5qkn6t+ btp5Wmcubmmt7M2TGFxAB22i4mdsIV9qDHURtjuAD0TohnoNpJIxxpP3+9jSr6iHG8W6 QU6g2A2loe7e2tUAMaetE5RUM0105YtU+1ZKmkYdZHNS2Bp0ocwekpvh86/Psa4zS8E/ uXzA== X-Gm-Message-State: APjAAAU++HLgbvtnMdQCfy2BHxidpThgK5wofK1ReFtmDa6mTRJEHpsn Yz0iZrhwNrydIKu50Quspxg= X-Google-Smtp-Source: APXvYqws6nRYSYz0R6XHyWlg+BYv6iqXM+SVEVrSsINEOjmeHi1LZwCuiGLtZKcURnf6Ix9nKqJLhg== X-Received: by 2002:a2e:9a51:: with SMTP id k17mr19128887ljj.206.1575977180051; Tue, 10 Dec 2019 03:26:20 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id e20sm1555481ljl.59.2019.12.10.03.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 03:26:18 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1iedem-0000wM-Ms; Tue, 10 Dec 2019 12:26:20 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, Johan Hovold , stable Subject: [PATCH 2/4] USB: adutux: fix interface sanity check Date: Tue, 10 Dec 2019 12:25:59 +0100 Message-Id: <20191210112601.3561-3-johan@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191210112601.3561-1-johan@kernel.org> References: <20191210112601.3561-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Make sure to use the current alternate setting when verifying the interface descriptors to avoid binding to an invalid interface. Failing to do so could cause the driver to misbehave or trigger a WARN() in usb_submit_urb() that kernels with panic_on_warn set would choke on. Fixes: 03270634e242 ("USB: Add ADU support for Ontrak ADU devices") Cc: stable # 2.6.19 Signed-off-by: Johan Hovold --- drivers/usb/misc/adutux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index 6f5edb9fc61e..d8d157c4c271 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c @@ -669,7 +669,7 @@ static int adu_probe(struct usb_interface *interface, init_waitqueue_head(&dev->read_wait); init_waitqueue_head(&dev->write_wait); - res = usb_find_common_endpoints_reverse(&interface->altsetting[0], + res = usb_find_common_endpoints_reverse(interface->cur_altsetting, NULL, NULL, &dev->interrupt_in_endpoint, &dev->interrupt_out_endpoint); From patchwork Tue Dec 10 11:26:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 11281909 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 26CBD138D for ; Tue, 10 Dec 2019 11:26:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0492208C3 for ; Tue, 10 Dec 2019 11:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575977185; bh=6ctoNcMor9QEcCPH/29/1+ym44YcwQhqRUvrkqjAkzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=UgF5XNssUdQcRe/CsFI/LPHLN1ZdaV8aS+BQx2n/pwL6yX/FG4AhGarCG2sa7Wcwh MdixkB7QwMOqvwmxTGcnL1KnmoCOehnnx25i4kzhX95+WLAtwRYHYkatfAOxLTcNWK 0IzPMrvJqUW/zdEmU2qaddIVP69Z+u6jkwUspbCE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727349AbfLJL0X (ORCPT ); Tue, 10 Dec 2019 06:26:23 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:46963 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726915AbfLJL0W (ORCPT ); Tue, 10 Dec 2019 06:26:22 -0500 Received: by mail-lj1-f194.google.com with SMTP id z17so19383488ljk.13; Tue, 10 Dec 2019 03:26:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5OsDhYumquwD8URBJRA6LU7R9HQWBfpM9E2aQ/J5j10=; b=kCfCcmIz7O3FHcYNk9dcq0gVZPOB5qtqEUynUeFOBy5AlGxyXWBTOCStMbPwoDE6LN WOILKu5ET0QCz78gCRLxAbcapWK9vJn/zGCk8ZMfRqg/BAKXGrLaOM4+tJ3HS5qva4wT Lguw5hV2FTyz2y16OYlAGp0IcNP/ma3sNcZPHYU8zphGSGznBVLARZmpyu+19G7lOwna j5uhxQ3IlfDVDPJK+mXbTbyy4ba/i+QwvLLmABkG++4Bu64nBOa1m9ZN+cJ/9IgXsTT/ 5L8VIExGVJlnt3i1OgcK7+HkjUZQGzmzncjIRK5OYJWqupUWwBGG/8kAZaY4SxNho9og 4+xw== X-Gm-Message-State: APjAAAWqggWRFrWJZCLJFyZs0+WvVT5/gX3qOvy3ejsyMCPDL50Xgkdj DTBB/HXgRSamKXk4HA3Xk2c= X-Google-Smtp-Source: APXvYqx0/P79/eyW7tmUaqkenv3wqIuiPmwLIEY5+OlcYaubkM/Q36layzZZQRRxI3MNq/Lxad+Iuw== X-Received: by 2002:a2e:9f52:: with SMTP id v18mr17566281ljk.30.1575977180545; Tue, 10 Dec 2019 03:26:20 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id t6sm1568848ljj.62.2019.12.10.03.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 03:26:18 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1iedem-0000wa-PR; Tue, 10 Dec 2019 12:26:20 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, Johan Hovold , stable Subject: [PATCH 3/4] USB: idmouse: fix interface sanity checks Date: Tue, 10 Dec 2019 12:26:00 +0100 Message-Id: <20191210112601.3561-4-johan@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191210112601.3561-1-johan@kernel.org> References: <20191210112601.3561-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Make sure to use the current alternate setting when verifying the interface descriptors to avoid binding to an invalid interface. Failing to do so could cause the driver to misbehave or trigger a WARN() in usb_submit_urb() that kernels with panic_on_warn set would choke on. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable Signed-off-by: Johan Hovold --- drivers/usb/misc/idmouse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index 4afb5ddfd361..e9437a176518 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c @@ -322,7 +322,7 @@ static int idmouse_probe(struct usb_interface *interface, int result; /* check if we have gotten the data or the hid interface */ - iface_desc = &interface->altsetting[0]; + iface_desc = interface->cur_altsetting; if (iface_desc->desc.bInterfaceClass != 0x0A) return -ENODEV; From patchwork Tue Dec 10 11:26:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 11281911 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D3CE188B for ; Tue, 10 Dec 2019 11:26:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B7F82073B for ; Tue, 10 Dec 2019 11:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575977185; bh=CAQH0WCgw7b6MZBhxw0+PInqP8HSmUE42xxX/dMPkuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Wg5J3eVGgYugPjuSxFeglX/+jY9C9W2squNaSSk97Lp79qMQwUYIQNWzGRzcmTPgo JkAtsr6+S+k0Y6Fk9Eiq4Gcw+Aa7KSYNjv/hT75csWyaiN/wLmgXp9aotBcJRo+U/7 ATMiSftZ0l6bLjHvuuH8X8wHfbCQTRH0CzBduec8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727377AbfLJL0X (ORCPT ); Tue, 10 Dec 2019 06:26:23 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36546 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727283AbfLJL0X (ORCPT ); Tue, 10 Dec 2019 06:26:23 -0500 Received: by mail-lf1-f68.google.com with SMTP id n12so13421832lfe.3; Tue, 10 Dec 2019 03:26:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vd4nd1Up2bQ7tpU0JXm2a/RtBZNBipYvR1ZZpNdym4w=; b=a9cEIIKLHw8Nzg8/YHBnEWizU/S4GkSiGBm7x+V6GYAXTGv2R7X0EB/ERWf04BswXC OE7lpfEoO9jXf4LfA3DA+REi2Ew/MB6PH2TR6/WDHa+3JiRF2YoY4osFhHxGe8xDpji3 xx9jgBg/S6t9YCmfqhBcjBNXTynhLq6qYLj8bgfV/C/7XVCxPaDC32R+aY7pI+8RF1/t ueXSxNO4oytmIa3vM09jUbFHxoyoLbuYTdFt27xoxoUUKZpMa7PbgfE83djGBCxFtOul exkElJfBkJU49so0HtbUtbG5Of8r1H0qxn/Jcfjj4mNlCxPQBIDOpBCGj5csESY8X37H /IbA== X-Gm-Message-State: APjAAAWIinDiwoHEHEdMm7WgL82ix73kUsepgz3ZNNrYj+fxgvgI/3Md FTeBN6esilzWM8AKjPKY6Xg= X-Google-Smtp-Source: APXvYqw61tI0RVbb+poLLhSndu5+FNHIJU4U3zCufXWLVUrSKyQBIPhU4AtxWwjAaaVsNFt2zVW9Cw== X-Received: by 2002:ac2:57cc:: with SMTP id k12mr4594540lfo.36.1575977181055; Tue, 10 Dec 2019 03:26:21 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id y7sm1392094lfe.7.2019.12.10.03.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 03:26:20 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1iedem-0000wf-S2; Tue, 10 Dec 2019 12:26:20 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, Johan Hovold , stable Subject: [PATCH 4/4] USB: serial: io_edgeport: fix epic endpoint lookup Date: Tue, 10 Dec 2019 12:26:01 +0100 Message-Id: <20191210112601.3561-5-johan@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191210112601.3561-1-johan@kernel.org> References: <20191210112601.3561-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Make sure to use the current alternate setting when looking up the endpoints on epic devices to avoid binding to an invalid interface. Failing to do so could cause the driver to misbehave or trigger a WARN() in usb_submit_urb() that kernels with panic_on_warn set would choke on. Fixes: 6e8cf7751f9f ("USB: add EPIC support to the io_edgeport driver") Cc: stable # 2.6.21 Signed-off-by: Johan Hovold --- drivers/usb/serial/io_edgeport.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 48a439298a68..9690a5f4b9d6 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -2901,16 +2901,18 @@ static int edge_startup(struct usb_serial *serial) response = 0; if (edge_serial->is_epic) { + struct usb_host_interface *alt; + + alt = serial->interface->cur_altsetting; + /* EPIC thing, set up our interrupt polling now and our read * urb, so that the device knows it really is connected. */ interrupt_in_found = bulk_in_found = bulk_out_found = false; - for (i = 0; i < serial->interface->altsetting[0] - .desc.bNumEndpoints; ++i) { + for (i = 0; i < alt->desc.bNumEndpoints; ++i) { struct usb_endpoint_descriptor *endpoint; int buffer_size; - endpoint = &serial->interface->altsetting[0]. - endpoint[i].desc; + endpoint = &alt->endpoint[i].desc; buffer_size = usb_endpoint_maxp(endpoint); if (!interrupt_in_found && (usb_endpoint_is_int_in(endpoint))) {