<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/usb/gadget/composite.c, branch v4.10</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>usb: gadget: composite: Fix function used to free memory</title>
<updated>2017-01-12T07:58:05+00:00</updated>
<author>
<name>Christophe JAILLET</name>
<email>christophe.jaillet@wanadoo.fr</email>
</author>
<published>2017-01-04T05:30:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=990758c53eafe5a220a780ed12e7b4d51b3df032'/>
<id>990758c53eafe5a220a780ed12e7b4d51b3df032</id>
<content type='text'>
'cdev-&gt;os_desc_req' has been allocated with 'usb_ep_alloc_request()' so
'usb_ep_free_request()' should be used to free it.

Signed-off-by: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
'cdev-&gt;os_desc_req' has been allocated with 'usb_ep_alloc_request()' so
'usb_ep_free_request()' should be used to free it.

Signed-off-by: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: gadget: composite: Test get_alt() presence instead of set_alt()</title>
<updated>2017-01-02T08:55:28+00:00</updated>
<author>
<name>Krzysztof Opasiak</name>
<email>k.opasiak@samsung.com</email>
</author>
<published>2016-12-20T18:52:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7e4da3fcf7c9fe042f2f7cb7bf23861a899b4a8f'/>
<id>7e4da3fcf7c9fe042f2f7cb7bf23861a899b4a8f</id>
<content type='text'>
By convention (according to doc) if function does not provide
get_alt() callback composite framework should assume that it has only
altsetting 0 and should respond with error if host tries to set
other one.

After commit dd4dff8b035f ("USB: composite: Fix bug: should test
set_alt function pointer before use it")
we started checking set_alt() callback instead of get_alt().
This check is useless as we check if set_alt() is set inside
usb_add_function() and fail if it's NULL.

Let's fix this check and move comment about why we check the get
method instead of set a little bit closer to prevent future false
fixes.

Fixes: dd4dff8b035f ("USB: composite: Fix bug: should test set_alt function pointer before use it")
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Krzysztof Opasiak &lt;k.opasiak@samsung.com&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
By convention (according to doc) if function does not provide
get_alt() callback composite framework should assume that it has only
altsetting 0 and should respond with error if host tries to set
other one.

After commit dd4dff8b035f ("USB: composite: Fix bug: should test
set_alt function pointer before use it")
we started checking set_alt() callback instead of get_alt().
This check is useless as we check if set_alt() is set inside
usb_add_function() and fail if it's NULL.

Let's fix this check and move comment about why we check the get
method instead of set a little bit closer to prevent future false
fixes.

Fixes: dd4dff8b035f ("USB: composite: Fix bug: should test set_alt function pointer before use it")
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Krzysztof Opasiak &lt;k.opasiak@samsung.com&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: gadget: composite: use kasprintf() instead of open coding it</title>
<updated>2016-11-03T08:38:36+00:00</updated>
<author>
<name>Juergen Gross</name>
<email>jgross@suse.com</email>
</author>
<published>2016-10-10T10:48:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=5002c93135947881f4f35caadf7292f40df7ef6b'/>
<id>5002c93135947881f4f35caadf7292f40df7ef6b</id>
<content type='text'>
Let's not reimplement generic kernel helpers,
instead call kasprintf().

[ felipe.balbi@linux.intel.com: better commit log ]

Signed-off-by: Juergen Gross &lt;jgross@suse.com&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Let's not reimplement generic kernel helpers,
instead call kasprintf().

[ felipe.balbi@linux.intel.com: better commit log ]

Signed-off-by: Juergen Gross &lt;jgross@suse.com&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: gadget: composite: remove unnecessary &amp; operation</title>
<updated>2016-11-03T08:38:24+00:00</updated>
<author>
<name>Felipe Balbi</name>
<email>felipe.balbi@linux.intel.com</email>
</author>
<published>2016-09-28T11:17:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9ad587710a2f7704d47ddb49ce60c909be836c2b'/>
<id>9ad587710a2f7704d47ddb49ce60c909be836c2b</id>
<content type='text'>
Now that usb_endpoint_maxp() only returns the lowest
11 bits from wMaxPacketSize, we can remove the &amp;
operation from this driver.

Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that usb_endpoint_maxp() only returns the lowest
11 bits from wMaxPacketSize, we can remove the &amp;
operation from this driver.

Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: gadget: composite: always set ep-&gt;mult to a sensible value</title>
<updated>2016-10-31T09:15:33+00:00</updated>
<author>
<name>Felipe Balbi</name>
<email>felipe.balbi@linux.intel.com</email>
</author>
<published>2016-09-28T09:33:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=eaa496ffaaf19591fe471a36cef366146eeb9153'/>
<id>eaa496ffaaf19591fe471a36cef366146eeb9153</id>
<content type='text'>
ep-&gt;mult is supposed to be set to Isochronous and
Interrupt Endapoint's multiplier value. This value
is computed from different places depending on the
link speed.

If we're dealing with HighSpeed, then it's part of
bits [12:11] of wMaxPacketSize. This case wasn't
taken into consideration before.

While at that, also make sure the ep-&gt;mult defaults
to one so drivers can use it unconditionally and
assume they'll never multiply ep-&gt;maxpacket to zero.

Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ep-&gt;mult is supposed to be set to Isochronous and
Interrupt Endapoint's multiplier value. This value
is computed from different places depending on the
link speed.

If we're dealing with HighSpeed, then it's part of
bits [12:11] of wMaxPacketSize. This case wasn't
taken into consideration before.

While at that, also make sure the ep-&gt;mult defaults
to one so drivers can use it unconditionally and
assume they'll never multiply ep-&gt;maxpacket to zero.

Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: gadget: composite: correctly initialize ep-&gt;maxpacket</title>
<updated>2016-10-31T09:15:33+00:00</updated>
<author>
<name>Felipe Balbi</name>
<email>felipe.balbi@linux.intel.com</email>
</author>
<published>2016-09-28T07:38:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e8f29bb719b47a234f33b0af62974d7a9521a52c'/>
<id>e8f29bb719b47a234f33b0af62974d7a9521a52c</id>
<content type='text'>
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-&gt;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: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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-&gt;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: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: gadget: composite: let USB functions process ctrl reqs in cfg0</title>
<updated>2016-08-25T09:13:17+00:00</updated>
<author>
<name>Felix Hädicke</name>
<email>felixhaedicke@web.de</email>
</author>
<published>2016-06-21T23:12:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=1a00b457a5482c3822bfc0fd64c088b2dba93e26'/>
<id>1a00b457a5482c3822bfc0fd64c088b2dba93e26</id>
<content type='text'>
It can sometimes be necessary for gadget drivers to process non-standard
control requests, which host devices can send without having sent
USB_REQ_SET_CONFIGURATION.

Therefore, the req_match() usb_function method is enhanced with the new
parameter "config0". When a USB configuration is active, this parameter
is false. When a non-core control request is processed in
composite_setup(), without an active configuration, req_match() of the
USB functions of all available configurations which implement this
function, is called with config0=true. Then the control request gets
processed by the first usb_function instance whose req_match() returns
true.

Signed-off-by: Felix Hädicke &lt;felixhaedicke@web.de&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It can sometimes be necessary for gadget drivers to process non-standard
control requests, which host devices can send without having sent
USB_REQ_SET_CONFIGURATION.

Therefore, the req_match() usb_function method is enhanced with the new
parameter "config0". When a USB configuration is active, this parameter
is false. When a non-core control request is processed in
composite_setup(), without an active configuration, req_match() of the
USB functions of all available configurations which implement this
function, is called with config0=true. Then the control request gets
processed by the first usb_function instance whose req_match() returns
true.

Signed-off-by: Felix Hädicke &lt;felixhaedicke@web.de&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: gadget: composite: Fix return value in case of error</title>
<updated>2016-08-11T12:09:46+00:00</updated>
<author>
<name>Christophe JAILLET</name>
<email>christophe.jaillet@wanadoo.fr</email>
</author>
<published>2016-07-16T06:34:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=3887db5c2b6531c59e9649a4293071b575d6eb3b'/>
<id>3887db5c2b6531c59e9649a4293071b575d6eb3b</id>
<content type='text'>
In 'composite_os_desc_req_prepare', if one of the memory allocations fail,
0 will be returned, which means success.
We should return -ENOMEM instead.

Signed-off-by: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In 'composite_os_desc_req_prepare', if one of the memory allocations fail,
0 will be returned, which means success.
We should return -ENOMEM instead.

Signed-off-by: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: gadget: composite: fix dereference after null check coverify warning</title>
<updated>2016-08-11T12:09:44+00:00</updated>
<author>
<name>Peter Chen</name>
<email>peter.chen@nxp.com</email>
</author>
<published>2016-07-01T07:33:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c526c62d565ea5a5bba9433f28756079734f430d'/>
<id>c526c62d565ea5a5bba9433f28756079734f430d</id>
<content type='text'>
cdev-&gt;config is checked for null pointer at above code, so cdev-&gt;config
might be null, fix it by adding null pointer check.

Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
cdev-&gt;config is checked for null pointer at above code, so cdev-&gt;config
might be null, fix it by adding null pointer check.

Signed-off-by: Peter Chen &lt;peter.chen@nxp.com&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>usb: gadget: composite: don't queue OS desc req if length is invalid</title>
<updated>2016-05-31T08:24:31+00:00</updated>
<author>
<name>William Wu</name>
<email>william.wu@rock-chips.com</email>
</author>
<published>2016-05-13T10:30:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7e14f47a55ed67c9d8a8acea6023412f92bac936'/>
<id>7e14f47a55ed67c9d8a8acea6023412f92bac936</id>
<content type='text'>
In OS descriptors handling, if ctrl-&gt;bRequestType is
USB_RECIP_DEVICE and w_index != 0x4 or (w_value &gt;&gt; 8)
is true, it will not assign a valid value to req-&gt;length,
but use the default value(-EOPNOTSUPP), and queue an
OS desc request with the invalid req-&gt;length. It always
happens on the platforms which use os_desc (for example:
rk3366, rk3399), and cause kernel panic as follows
(use dwc3 driver):

Unable to handle kernel paging request at virtual address ffffffc0f7e00000
Internal error: Oops: 96000146 [#1] PREEMPT SMP
PC is at __dma_clean_range+0x18/0x30
LR is at __swiotlb_map_page+0x50/0x64
Call trace:
[&lt;ffffffc0000930f8&gt;] __dma_clean_range+0x18/0x30
[&lt;ffffffc00062214c&gt;] usb_gadget_map_request+0x134/0x1b0
[&lt;ffffffc0005c289c&gt;] __dwc3_ep0_do_control_data+0x110/0x14c
[&lt;ffffffc0005c2d38&gt;] __dwc3_gadget_ep0_queue+0x198/0x1b8
[&lt;ffffffc0005c2e18&gt;] dwc3_gadget_ep0_queue+0xc0/0xe8
[&lt;ffffffc00061cfec&gt;] composite_ep0_queue.constprop.14+0x34/0x98
[&lt;ffffffc00061dfb0&gt;] composite_setup+0xf60/0x100c
[&lt;ffffffc0006204dc&gt;] android_setup+0xd8/0x138
[&lt;ffffffc0005c29a4&gt;] dwc3_ep0_delegate_req+0x34/0x50
[&lt;ffffffc0005c3534&gt;] dwc3_ep0_interrupt+0x5dc/0xb58
[&lt;ffffffc0005c0c3c&gt;] dwc3_thread_interrupt+0x15c/0xa24

With this patch, the gadget driver will not queue
a request and return immediately if req-&gt;length is
invalid. And the usb controller driver can handle
the unsupport request correctly.

Signed-off-by: William Wu &lt;william.wu@rock-chips.com&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In OS descriptors handling, if ctrl-&gt;bRequestType is
USB_RECIP_DEVICE and w_index != 0x4 or (w_value &gt;&gt; 8)
is true, it will not assign a valid value to req-&gt;length,
but use the default value(-EOPNOTSUPP), and queue an
OS desc request with the invalid req-&gt;length. It always
happens on the platforms which use os_desc (for example:
rk3366, rk3399), and cause kernel panic as follows
(use dwc3 driver):

Unable to handle kernel paging request at virtual address ffffffc0f7e00000
Internal error: Oops: 96000146 [#1] PREEMPT SMP
PC is at __dma_clean_range+0x18/0x30
LR is at __swiotlb_map_page+0x50/0x64
Call trace:
[&lt;ffffffc0000930f8&gt;] __dma_clean_range+0x18/0x30
[&lt;ffffffc00062214c&gt;] usb_gadget_map_request+0x134/0x1b0
[&lt;ffffffc0005c289c&gt;] __dwc3_ep0_do_control_data+0x110/0x14c
[&lt;ffffffc0005c2d38&gt;] __dwc3_gadget_ep0_queue+0x198/0x1b8
[&lt;ffffffc0005c2e18&gt;] dwc3_gadget_ep0_queue+0xc0/0xe8
[&lt;ffffffc00061cfec&gt;] composite_ep0_queue.constprop.14+0x34/0x98
[&lt;ffffffc00061dfb0&gt;] composite_setup+0xf60/0x100c
[&lt;ffffffc0006204dc&gt;] android_setup+0xd8/0x138
[&lt;ffffffc0005c29a4&gt;] dwc3_ep0_delegate_req+0x34/0x50
[&lt;ffffffc0005c3534&gt;] dwc3_ep0_interrupt+0x5dc/0xb58
[&lt;ffffffc0005c0c3c&gt;] dwc3_thread_interrupt+0x15c/0xa24

With this patch, the gadget driver will not queue
a request and return immediately if req-&gt;length is
invalid. And the usb controller driver can handle
the unsupport request correctly.

Signed-off-by: William Wu &lt;william.wu@rock-chips.com&gt;
Signed-off-by: Felipe Balbi &lt;felipe.balbi@linux.intel.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
