Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp478620ybl; Tue, 28 Jan 2020 06:35:25 -0800 (PST) X-Google-Smtp-Source: APXvYqykIm0V1sreybowSRKxt/aKGGmIVWX2M26Dk03of1sd/9d0Hd/EE6DJlyMvckbDnIrazWxC X-Received: by 2002:a05:6808:681:: with SMTP id k1mr2928104oig.143.1580222125481; Tue, 28 Jan 2020 06:35:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580222125; cv=none; d=google.com; s=arc-20160816; b=MO6/cRRfA7vHIk12NwK0TTpMAjTieI6Kvp34q2zV4Re0YHgwP2LnWv7VI4zFbpwjWo t/Lrm6RmkA4UJZtmFUzj+llK+fmAWyPeMPaP9EWkmh884mXVEGA+ih9mYijvjmazzb+T OxsAyA3dchzviENh5OuHAmLgLQy2x9NWICQKsnYqOyGvh0iatnZC84U2CZGhIPWlepe8 qQBPqE8/WPnkvsSDFI3WxAILtjPmbxvhfj0r41EYe6m2oglnqhfzPeQxgHQDk7JewMEk Ayb220vhfoRIJiAOe+BDa+RRqTJZHF61Pscp5d4lqu71Lfn1hwstZOJwQgHjqT597Wld tL+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ro034YUM7ZROrGu+GRUUm1lquFmCtZVOO9D3pUHKTbI=; b=rCNtPihhLzzOSoFKXRQ+sTI69/8Avri+yTR2C6d/vsivk4+8jcgAvLK9/doGobDWrk 3/PilbtBOp8l4iYQlxTul7U8/RWtmH+o3TQPqUJS6Dv2w8UgoSWuy5mzvniV7jZGEYdg /McovCdPDxOCo1oAwjN+EtvsBG5DCDYdhVYvJ5RmPdKR1CveIRp/QawzZL8Sioyx7Ivl QdqZE+Uza0hzLlu7EOHB7WnsUF6UDAPsj4ZyUIKbc+3doH0fRHBU8tKh6tUMfBI2K6Z3 4dFZUuRntCau+k5bDrLyV8qzUQwIjMFpbGNQyTfmpzggqIVRu+p/mf6iol1N2Tr+5Ne7 WF7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DyyRYAlE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s7si2632351otd.280.2020.01.28.06.35.14; Tue, 28 Jan 2020 06:35:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DyyRYAlE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733162AbgA1Ode (ORCPT + 99 others); Tue, 28 Jan 2020 09:33:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:52086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732869AbgA1OZL (ORCPT ); Tue, 28 Jan 2020 09:25:11 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 D14D121739; Tue, 28 Jan 2020 14:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221510; bh=C80hO95fUlhePgToChD8CSc4I8Aj6cloQwLGUMaNs+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DyyRYAlEw7hxIGLGSb0ZEkRxpnQoes8dIU+2sIfRjgdEw856q2f4dsdV6AjwMYjqu x+9CmW/a9TawulEnXH3vSwWAmQMCsrJqVBEkHiWmbn+dXOpKc6g4tPqnRhNPGpb9rk 2KWKpV3XLXdNr5pqevsuNdCcqWMqhAjKa3/Xl/5g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Vladis Dronov , Dmitry Torokhov Subject: [PATCH 4.9 253/271] Input: gtco - fix endpoint sanity check Date: Tue, 28 Jan 2020 15:06:42 +0100 Message-Id: <20200128135911.409469855@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold commit a8eeb74df5a6bdb214b2b581b14782c5f5a0cf83 upstream. The driver was checking the number of endpoints of the first alternate setting instead of the current one, something which could lead to the driver binding to an invalid interface. This in turn 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: 162f98dea487 ("Input: gtco - fix crash on detecting device without endpoints") Signed-off-by: Johan Hovold Acked-by: Vladis Dronov Link: https://lore.kernel.org/r/20191210113737.4016-5-johan@kernel.org Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/tablet/gtco.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) --- a/drivers/input/tablet/gtco.c +++ b/drivers/input/tablet/gtco.c @@ -875,18 +875,14 @@ static int gtco_probe(struct usb_interfa } /* Sanity check that a device has an endpoint */ - if (usbinterface->altsetting[0].desc.bNumEndpoints < 1) { + if (usbinterface->cur_altsetting->desc.bNumEndpoints < 1) { dev_err(&usbinterface->dev, "Invalid number of endpoints\n"); error = -EINVAL; goto err_free_urb; } - /* - * The endpoint is always altsetting 0, we know this since we know - * this device only has one interrupt endpoint - */ - endpoint = &usbinterface->altsetting[0].endpoint[0].desc; + endpoint = &usbinterface->cur_altsetting->endpoint[0].desc; /* Some debug */ dev_dbg(&usbinterface->dev, "gtco # interfaces: %d\n", usbinterface->num_altsetting); @@ -973,7 +969,7 @@ static int gtco_probe(struct usb_interfa input_dev->dev.parent = &usbinterface->dev; /* Setup the URB, it will be posted later on open of input device */ - endpoint = &usbinterface->altsetting[0].endpoint[0].desc; + endpoint = &usbinterface->cur_altsetting->endpoint[0].desc; usb_fill_int_urb(gtco->urbinfo, udev,