Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp457432ybl; Tue, 28 Jan 2020 06:16:52 -0800 (PST) X-Google-Smtp-Source: APXvYqxekjyBluIw0F/FYps1FwZuVptCCmwLk7ehFYeChVGYYh1LKPrH/6CZFlErpC570zDvIORa X-Received: by 2002:a9d:5885:: with SMTP id x5mr16115497otg.132.1580221012522; Tue, 28 Jan 2020 06:16:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580221012; cv=none; d=google.com; s=arc-20160816; b=C1wo/PuDoGsXth2LCtMl8OXbtaQXKdCnoSyK3KoyOd2Am8kswOy8fovgyGuvkq+rzZ EFWjvJdWjJnxfy7QoWdFsTTEHiRZlYzRPP3Zb7XUmkuFk1sOEiShzI/DS8TWbKNUlybe vYCzVhgYByro8ZnMmWENhEQje1aDLFZ1dioBmRn3QYnV8Zns697GCQMCcDzHRJg+2RSQ 9iHNda2ydzzqtZiVPwONQi/MsCTZmHNQRi1RwcFg7w3RCGRod/3WIHIRRY9AXgso2Ii9 lQgw3JOToPMdxMKO/QrtEgDZsk3tRTqimwKZSZ/wQtGh8FVzdK4TI6ApiX3Hh/2WETGe 9rXQ== 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=p6UUxdToB8Frjs6tBXffz+MLg2N/PXp4Pj83TYkc6B8=; b=B7vbu7v44RE4H0UN4dAG4iYb+M3FYnAlTsI3euPWt/jknx9u54bNfZQcxpTB71swzf pdssbjm69xZpPxjjB7Dz5k781zoAnOr3o1k0hw3SPQmRFkqVcf9x/5UR9vTG/Mvl2cP1 uYvS6ZTTg4Vve0KmJarPhhDLfflSCYkR15vDZ5pbIOdCoUH9sk+lVLW1ZhKeV9uQ2Cz1 1sghsBWqEYMIZzN4IsxTM0HL6m9bBtqvQRGOOJf2AlHN7Tw1zcUUcKLBiP8PdUM3tMRR IPTkt5dDu/SoA2YwcS+4Q31ojplVaFzTkgSYZapcrfT/g/acPROMrt4yYaJx8dN31ry3 dmzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iHi1ykTY; 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 e1si7331813otr.8.2020.01.28.06.16.10; Tue, 28 Jan 2020 06:16:52 -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=iHi1ykTY; 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 S1728309AbgA1OOL (ORCPT + 99 others); Tue, 28 Jan 2020 09:14:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:36094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729819AbgA1OOI (ORCPT ); Tue, 28 Jan 2020 09:14:08 -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 A486B2468E; Tue, 28 Jan 2020 14:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580220848; bh=N2yMitmW+bURp6dgZaaSsfFa0kb7TjFta9YQBQYuVVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iHi1ykTYpyWrnmlHc3zJn1rphENKV2YddNx/JMY1KVc99+tC0paZVAQNqzuwtnGhQ JLTsrmSb6Egasnh05BbvjuN5966zIAZ4sL7cTp0+uek/r1vYumq1J84qq5eANcCNSc iZ1Ag95uYPMFFEp4P9AOedB0pa0UjyalgXHBbZTA= 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.4 171/183] Input: gtco - fix endpoint sanity check Date: Tue, 28 Jan 2020 15:06:30 +0100 Message-Id: <20200128135846.827190584@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135829.486060649@linuxfoundation.org> References: <20200128135829.486060649@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 @@ -876,18 +876,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); @@ -974,7 +970,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, gtco->usbdev,