From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com ([192.55.52.120]:42041 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932309AbcI1NGQ (ORCPT ); Wed, 28 Sep 2016 09:06:16 -0400 From: Felipe Balbi To: Linux USB Cc: Felipe Balbi , stable@vger.kernel.org Subject: [RFC/PATCH 02/45] usb: gadget: composite: correctly initialize ep->maxpacket Date: Wed, 28 Sep 2016 16:05:11 +0300 Message-Id: <20160928130554.29790-3-felipe.balbi@linux.intel.com> In-Reply-To: <20160928130554.29790-1-felipe.balbi@linux.intel.com> References: <20160928130554.29790-1-felipe.balbi@linux.intel.com> Sender: stable-owner@vger.kernel.org List-ID: usb_endpoint_maxp() returns wMaxPacketSize in its raw form. Without taking into consideration that it also contains other bits reserved for isochronous endpoints. This patch fixes one occasion where this is a problem by making sure that we initialize ep->maxpacket only with lower 10 bits of the value returned by usb_endpoint_maxp(). Note that seperate patches will be necessary to audit all call sites of usb_endpoint_maxp() and make sure that usb_endpoint_maxp() only returns lower 10 bits of wMaxPacketSize. Cc: Signed-off-by: Felipe Balbi --- drivers/usb/gadget/composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 32176f779861..f6a7583ab6d1 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -197,7 +197,7 @@ int config_ep_by_speed(struct usb_gadget *g, ep_found: /* commit results */ - _ep->maxpacket = usb_endpoint_maxp(chosen_desc); + _ep->maxpacket = usb_endpoint_maxp(chosen_desc) & 0x7ff; _ep->desc = chosen_desc; _ep->comp_desc = NULL; _ep->maxburst = 0; -- 2.10.0.440.g21f862b