Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp438964ybl; Tue, 28 Jan 2020 06:02:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzDsyDWqJecODpv32VQqV0spc8bEuNkDmpyMKJvL54sMuNrhdvICkG0R1vBnmhWpWBHmeiV X-Received: by 2002:aca:814:: with SMTP id 20mr2892977oii.159.1580220156571; Tue, 28 Jan 2020 06:02:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580220156; cv=none; d=google.com; s=arc-20160816; b=THTw7CxKIADh9zMtRRaNv+tz9Z+u4iF1d/3tjOxPVP2eG6iZSaiyXBS9eE4nBiuzIa XgIcw2GXExzQvks68QAsAzizc0BH/KhTsgo/YrIsoKr8FNoA8T9QEIVMIQQ24DROCOZI MsMpGZdoS7VEEysUswUQWDUYXa1rME62JsqZrx3f/ZMwbL4yZx7HTsmThvAClZ50KAtM d5sp0R4lvZT+SgfD+URdBbR575QuIovucfFYFL7plglC8VCUq1vXogVq8hbWM20puXBk 7IsLIO5uNqkry6iTY8gk/QcO1gFOJslsFEmOVrL4rv6F808UC1BtTUOdbRvK9+4trpCv ezew== 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=RJqfdjWfTkQgLkJqB/NTOG7E4kNmRaxEOPwnCJeCc1YauaoCYRm/qnSSAn4rDmDfcV Na+FYls1JvYX3wGQ2nuRkf3iDXrVArJXqThD4mmM5WH1F9cGMU1zqk8HZqXelZLI7w8I 90WKeB0FGdQtanGQvJ8lWycca+oqhmrfUnDS34qT/aNWgbxh1+g1wKj6togWbEFEud/b aPhRYaAf/qMev7VzD5OOZD0hsgHOC7YX6LGoXkGNW0GSBKKH2o9lfp+4ElLafNtgncAO toFuyCfgSP26k0pMSaU9mnW6lQmmJRdbRZmQnhTPw8LROysFyXBaxQZKPnZ52vDBPHJF bFFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P1VSoDzf; 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 v18si5128397otn.174.2020.01.28.06.02.16; Tue, 28 Jan 2020 06:02:36 -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=P1VSoDzf; 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 S1727196AbgA1OAG (ORCPT + 99 others); Tue, 28 Jan 2020 09:00:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:45626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726520AbgA1OAC (ORCPT ); Tue, 28 Jan 2020 09:00:02 -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 DE94324688; Tue, 28 Jan 2020 14:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580220002; bh=C80hO95fUlhePgToChD8CSc4I8Aj6cloQwLGUMaNs+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P1VSoDzfLfmQzjIYJ4gN1CJ0KJhcTiMyAOVaWaLQk8yXd+CiTZxWtv6V8PDy3S4bf 9kAbU+GFyZAwa4StAQQVf8LjKx6pN0vamK35pMbCsQKiLOjh5Ca3af1/AmTnsjIDU+ AUw5zBDBYfXoberAjJyLeoTzJ0cfm3GzmZaFVpA0= 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.14 29/46] Input: gtco - fix endpoint sanity check Date: Tue, 28 Jan 2020 14:58:03 +0100 Message-Id: <20200128135753.817028576@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135749.822297911@linuxfoundation.org> References: <20200128135749.822297911@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,