<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/usb/usb-skeleton.c, branch v6.12.80</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.12.80</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.12.80'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2022-11-29T07:56:09+00:00</updated>
<entry>
<title>usb: add usb_set_intfdata() documentation</title>
<updated>2022-11-29T07:56:09+00:00</updated>
<author>
<name>Vincent Mailhol</name>
<email>mailhol.vincent@wanadoo.fr</email>
</author>
<published>2022-11-28T10:29:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=27ef17849779edd5600aa27d1a246ad424761971'/>
<id>urn:sha1:27ef17849779edd5600aa27d1a246ad424761971</id>
<content type='text'>
USB drivers do not need to call usb_set_intfdata(intf, NULL) in their
usb_driver::disconnect callback because the core already does it in [1].

However, this fact is widely unknown, c.f.:

  $ git grep "usb_set_intfdata(.*NULL)" | wc -l
  215

Especially, setting the interface to NULL before all action completed
can result in a NULL pointer dereference. Not calling
usb_set_intfdata() at all in disconnect() is the safest method.

Add documentation to usb_set_intfdata() to clarify this point.

Also remove the call in usb-skeletion's disconnect() not to confuse
the new comers.

[1] function usb_unbind_interface() from drivers/usb/core/driver.c
Link: https://elixir.bootlin.com/linux/v6.0/source/drivers/usb/core/driver.c#L497

Signed-off-by: Vincent Mailhol &lt;mailhol.vincent@wanadoo.fr&gt;
Link: https://lore.kernel.org/r/20221128102954.3615579-1-mailhol.vincent@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: usb-skeleton: Update min() to min_t()</title>
<updated>2021-10-05T10:56:48+00:00</updated>
<author>
<name>Philipp Hortmann</name>
<email>philipp.g.hortmann@gmail.com</email>
</author>
<published>2021-09-22T21:20:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=8c9e880bb98cba546ffaf97b85c5111f0aa86f79'/>
<id>urn:sha1:8c9e880bb98cba546ffaf97b85c5111f0aa86f79</id>
<content type='text'>
This patch fixes the checkpatch.pl warning:
WARNING: min() should probably be min_t(size_t, count, MAX_TRANSFER)
+	size_t writesize = min(count, (size_t)MAX_TRANSFER);

Signed-off-by: Philipp Hortmann &lt;philipp.g.hortmann@gmail.com&gt;
Link: https://lore.kernel.org/r/20210922212037.GA8110@matrix-ESPRIMO-P710
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>USB: usb-skeleton: drop redundant in-urb check</title>
<updated>2019-10-10T10:41:19+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2019-10-09T17:09:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=369dca424a3f9ef80bc4e5a5ccdd41a17ce306c1'/>
<id>urn:sha1:369dca424a3f9ef80bc4e5a5ccdd41a17ce306c1</id>
<content type='text'>
The driver bails out at probe if we can't find a bulk-in endpoint or
if we fail to allocate the URB, so drop the check in read().

Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Link: https://lore.kernel.org/r/20191009170944.30057-4-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>USB: usb-skeleton: fix use-after-free after driver unbind</title>
<updated>2019-10-10T10:41:19+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2019-10-09T17:09:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6353001852776e7eeaab4da78922d4c6f2b076af'/>
<id>urn:sha1:6353001852776e7eeaab4da78922d4c6f2b076af</id>
<content type='text'>
The driver failed to stop its read URB on disconnect, something which
could lead to a use-after-free in the completion handler after driver
unbind in case the character device has been closed.

Fixes: e7389cc9a7ff ("USB: skel_read really sucks royally")
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Link: https://lore.kernel.org/r/20191009170944.30057-3-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>USB: usb-skeleton: fix NULL-deref on disconnect</title>
<updated>2019-10-10T10:41:18+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2019-10-09T17:09:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=bed5ef230943863b9abf5eae226a20fad9a8ff71'/>
<id>urn:sha1:bed5ef230943863b9abf5eae226a20fad9a8ff71</id>
<content type='text'>
The driver was using its struct usb_interface pointer as an inverted
disconnected flag and was setting it to NULL before making sure all
completion handlers had run. This could lead to NULL-pointer
dereferences in the dev_err() statements in the completion handlers
which relies on said pointer.

Fix this by using a dedicated disconnected flag.

Note that this is also addresses a NULL-pointer dereference at release()
and a struct usb_interface reference leak introduced by a recent runtime
PM fix, which depends on and should have been submitted together with
this patch.

Fixes: 4212cd74ca6f ("USB: usb-skeleton.c: remove err() usage")
Fixes: 5c290a5e42c3 ("USB: usb-skeleton: fix runtime PM after driver unbind")
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Link: https://lore.kernel.org/r/20191009170944.30057-2-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>USB: usb-skeleton: fix runtime PM after driver unbind</title>
<updated>2019-10-04T12:38:45+00:00</updated>
<author>
<name>Johan Hovold</name>
<email>johan@kernel.org</email>
</author>
<published>2019-10-01T08:49:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=5c290a5e42c3387e82de86965784d30e6c5270fd'/>
<id>urn:sha1:5c290a5e42c3387e82de86965784d30e6c5270fd</id>
<content type='text'>
Since commit c2b71462d294 ("USB: core: Fix bug caused by duplicate
interface PM usage counter") USB drivers must always balance their
runtime PM gets and puts, including when the driver has already been
unbound from the interface.

Leaving the interface with a positive PM usage counter would prevent a
later bound driver from suspending the device.

Fixes: c2b71462d294 ("USB: core: Fix bug caused by duplicate interface PM usage counter")
Cc: stable &lt;stable@vger.kernel.org&gt;
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Link: https://lore.kernel.org/r/20191001084908.2003-2-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: usb-skeleton: make comment block in line with coding style</title>
<updated>2019-08-21T16:57:36+00:00</updated>
<author>
<name>Jacob Huisman</name>
<email>jacobhuisman@kernelthusiast.com</email>
</author>
<published>2019-08-15T17:42:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a599e48662b4b505bef45d4831061f9d50703e17'/>
<id>urn:sha1:a599e48662b4b505bef45d4831061f9d50703e17</id>
<content type='text'>
Comment block was not in accordance with coding style.
Fixes two checkpatch warnings:
WARNING: Block comments use * on subsequent lines
WARNING: Block comments use a trailing */ on a separate line

Signed-off-by: Jacob Huisman &lt;jacobhuisman@kernelthusiast.com&gt;
Link: https://lore.kernel.org/r/20190815174210.580-1-jacobhuisman@kernelthusiast.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: usb-skeleton: use irqsave() in USB's complete callback</title>
<updated>2018-06-28T10:36:06+00:00</updated>
<author>
<name>John Ogness</name>
<email>john.ogness@linutronix.de</email>
</author>
<published>2018-06-24T22:08:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=8982c8440f564549261fb80ca3fe1e3266635936'/>
<id>urn:sha1:8982c8440f564549261fb80ca3fe1e3266635936</id>
<content type='text'>
The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness &lt;john.ogness@linutronix.de&gt;
Signed-off-by: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: usb-skeleton: make MODULE_LICENSE and SPDX tag match</title>
<updated>2018-03-06T17:42:07+00:00</updated>
<author>
<name>Marcus Folkesson</name>
<email>marcus.folkesson@gmail.com</email>
</author>
<published>2018-03-01T07:55:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e4c4835171a537d7acb66b21c6f6a046409aa586'/>
<id>urn:sha1:e4c4835171a537d7acb66b21c6f6a046409aa586</id>
<content type='text'>
GPL v2 is the original license according to the old license text.
See f64cdd0e94f1faf3b7f2b03af71f70dc6d8da0c2.

Signed-off-by: Marcus Folkesson &lt;marcus.folkesson@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>USB: usb-skeleton: Remove redundant license text</title>
<updated>2017-11-04T10:55:39+00:00</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2017-11-03T11:41:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f64cdd0e94f1faf3b7f2b03af71f70dc6d8da0c2'/>
<id>urn:sha1:f64cdd0e94f1faf3b7f2b03af71f70dc6d8da0c2</id>
<content type='text'>
Now that the SPDX tag is in all USB files, that identifies the license
in a specific and legally-defined manner.  So the extra GPL text wording
can be removed as it is no longer needed at all.

This is done on a quest to remove the 700+ different ways that files in
the kernel describe the GPL license text.  And there's unneeded stuff
like the address (sometimes incorrect) for the FSF which is never
needed.

No copyright headers or other non-license-description text was removed.

Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
