<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/bluetooth/hci_serdev.c, branch linux-4.19.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.19.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.19.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2022-04-15T12:14:47Z</updated>
<entry>
<title>Bluetooth: hci_serdev: call init_rwsem() before p-&gt;open()</title>
<updated>2022-04-15T12:14:47Z</updated>
<author>
<name>Pavel Skripkin</name>
</author>
<published>2022-01-13T13:27:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7af24ae489f7932f8f6a9786f755578555c110aa'/>
<id>urn:sha1:7af24ae489f7932f8f6a9786f755578555c110aa</id>
<content type='text'>
[ Upstream commit 9d7cbe2b9cf5f650067df4f402fdd799d4bbb4e1 ]

kvartet reported, that hci_uart_tx_wakeup() uses uninitialized rwsem.
The problem was in wrong place for percpu_init_rwsem() call.

hci_uart_proto::open() may register a timer whose callback may call
hci_uart_tx_wakeup(). There is a chance, that hci_uart_register_device()
thread won't be fast enough to call percpu_init_rwsem().

Fix it my moving percpu_init_rwsem() call before p-&gt;open().

INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe
you didn't initialize this object before use?
turning off the locking correctness validator.
CPU: 2 PID: 18524 Comm: syz-executor.5 Not tainted 5.16.0-rc6 #9
...
Call Trace:
 &lt;IRQ&gt;
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 assign_lock_key kernel/locking/lockdep.c:951 [inline]
 register_lock_class+0x148d/0x1950 kernel/locking/lockdep.c:1263
 __lock_acquire+0x106/0x57e0 kernel/locking/lockdep.c:4906
 lock_acquire kernel/locking/lockdep.c:5637 [inline]
 lock_acquire+0x1ab/0x520 kernel/locking/lockdep.c:5602
 percpu_down_read_trylock include/linux/percpu-rwsem.h:92 [inline]
 hci_uart_tx_wakeup+0x12e/0x490 drivers/bluetooth/hci_ldisc.c:124
 h5_timed_event+0x32f/0x6a0 drivers/bluetooth/hci_h5.c:188
 call_timer_fn+0x1a5/0x6b0 kernel/time/timer.c:1421

Fixes: d73e17281665 ("Bluetooth: hci_serdev: Init hci_uart proto_lock to avoid oops")
Reported-by: Yiru Xu &lt;xyru1999@gmail.com&gt;
Signed-off-by: Pavel Skripkin &lt;paskripkin@gmail.com&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: hci_uart: Cancel init work before unregistering</title>
<updated>2020-10-29T08:55:05Z</updated>
<author>
<name>Samuel Holland</name>
</author>
<published>2020-08-01T16:29:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=aea63181b6fcb6b9ccde1ada9ea51be19c4015af'/>
<id>urn:sha1:aea63181b6fcb6b9ccde1ada9ea51be19c4015af</id>
<content type='text'>
[ Upstream commit 3b799254cf6f481460719023d7a18f46651e5e7f ]

If hci_uart_tty_close() or hci_uart_unregister_device() is called while
hu-&gt;init_ready is scheduled, hci_register_dev() could be called after
the hci_uart is torn down. Avoid this by ensuring the work is complete
or canceled before checking the HCI_UART_REGISTERED flag.

Fixes: 9f2aee848fe6 ("Bluetooth: Add delayed init sequence support for UART controllers")
Signed-off-by: Samuel Holland &lt;samuel@sholland.org&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: hci_serdev: Only unregister device if it was registered</title>
<updated>2020-08-19T06:15:00Z</updated>
<author>
<name>Nicolas Boichat</name>
</author>
<published>2020-07-21T02:37:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d30d21110706a0a197ec4803f5af1fa364e49826'/>
<id>urn:sha1:d30d21110706a0a197ec4803f5af1fa364e49826</id>
<content type='text'>
[ Upstream commit 202798db9570104728dce8bb57dfeed47ce764bc ]

We should not call hci_unregister_dev if the device was not
successfully registered.

Fixes: c34dc3bfa7642fd ("Bluetooth: hci_serdev: Introduce hci_uart_unregister_device()")
Signed-off-by: Nicolas Boichat &lt;drinkcat@chromium.org&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: hci_serdev: clear HCI_UART_PROTO_READY to avoid closing proto races</title>
<updated>2019-11-20T17:47:42Z</updated>
<author>
<name>Balakrishna Godavarthi</name>
</author>
<published>2018-08-22T12:04:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2c8946462f074603259cca407b89a19dc42832e7'/>
<id>urn:sha1:2c8946462f074603259cca407b89a19dc42832e7</id>
<content type='text'>
[ Upstream commit 7cf7846d27bfc9731e449857db3eec5e0e9701ba ]

Clearing HCI_UART_PROTO_READY will avoid usage of proto function pointers
before running the proto close function pointer. There is chance of kernel
crash, due to usage of non proto close function pointers after proto close.

Signed-off-by: Balakrishna Godavarthi &lt;bgodavar@codeaurora.org&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: hci_serdev: Fix HCI_UART_INIT_PENDING not working</title>
<updated>2018-05-30T06:49:20Z</updated>
<author>
<name>Hans de Goede</name>
</author>
<published>2018-05-27T19:04:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fdee6d8fc630fa82e06d792f3adadab3bd48666e'/>
<id>urn:sha1:fdee6d8fc630fa82e06d792f3adadab3bd48666e</id>
<content type='text'>
Init hci_uart-&gt;init_ready so that hci_uart_init_ready() works properly.

Signed-off-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: hci_serdev: Move serdev_device_close/open into common hci_serdev code</title>
<updated>2018-05-30T06:47:42Z</updated>
<author>
<name>Hans de Goede</name>
</author>
<published>2018-05-27T19:04:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e9ca08074ddcdcc3abacbfca888dba3a110e4453'/>
<id>urn:sha1:e9ca08074ddcdcc3abacbfca888dba3a110e4453</id>
<content type='text'>
Make hci_uart_register_device() and hci_uart_unregister_device() call
serdev_device_close()/open() themselves instead of relying on the various
hci_uart drivers to do this for them.

Besides reducing code complexity, this also ensures correct error checking
of serdev_device_open(), which was missing in a few drivers.

Signed-off-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: hci_uart: Restore hci_dev-&gt;flush callback on open()</title>
<updated>2018-05-30T06:46:17Z</updated>
<author>
<name>Hans de Goede</name>
</author>
<published>2018-05-27T19:04:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=412fe29ffcf9a1ba9f125e72ee3da957cd6a0064'/>
<id>urn:sha1:412fe29ffcf9a1ba9f125e72ee3da957cd6a0064</id>
<content type='text'>
For reasons explained in detail in commit 3611f4d2a5e0 ("hci_ldisc:
fix null pointer deref") the hci_uart_close() functions sets
hci_dev-&gt;flush to NULL.

But the device may be re-opened after a close, this commit restores the
hci_dev-&gt;flush callback on open().

Note this commit also moves the nearly empty defition of hci_uart_open()
a bit down in the file to avoid the need for forward declaring
hci_uart_flush().

Signed-off-by: Hans de Goede &lt;hdegoede@redhat.com&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: hci_serdev: Removed unnecessary curly braces</title>
<updated>2018-05-29T13:59:50Z</updated>
<author>
<name>Vaibhav Murkute</name>
</author>
<published>2018-05-14T21:38:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0c0c09ff09bb094bcd496b28b8ac4c8ae5b7a4a8'/>
<id>urn:sha1:0c0c09ff09bb094bcd496b28b8ac4c8ae5b7a4a8</id>
<content type='text'>
checkpatch.pl shows a warning for these unnecessary curly braces.
so just removed those curly braces.

Signed-off-by: Vaibhav Murkute &lt;vaibhavmurkute88@gmail.com&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: hci_serdev: Init hci_uart proto_lock to avoid oops</title>
<updated>2017-12-12T23:28:41Z</updated>
<author>
<name>Lukas Wunner</name>
</author>
<published>2017-11-16T23:54:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d73e172816652772114827abaa2dbc053eecbbd7'/>
<id>urn:sha1:d73e172816652772114827abaa2dbc053eecbbd7</id>
<content type='text'>
John Stultz reports a boot time crash with the HiKey board (which uses
hci_serdev) occurring in hci_uart_tx_wakeup().  That function is
contained in hci_ldisc.c, but also called from the newer hci_serdev.c.
It acquires the proto_lock in struct hci_uart and it turns out that we
forgot to init the lock in the serdev code path, thus causing the crash.

John bisected the crash to commit 67d2f8781b9f ("Bluetooth: hci_ldisc:
Allow sleeping while proto locks are held"), but the issue was present
before and the commit merely exposed it.  (Perhaps by luck, the crash
did not occur with rwlocks.)

Init the proto_lock in the serdev code path to avoid the oops.

Stack trace for posterity:

Unable to handle kernel read from unreadable memory at 406f127000
[000000406f127000] user address but active_mm is swapper
Internal error: Oops: 96000005 [#1] PREEMPT SMP
Hardware name: HiKey Development Board (DT)
Call trace:
 hci_uart_tx_wakeup+0x38/0x148
 hci_uart_send_frame+0x28/0x38
 hci_send_frame+0x64/0xc0
 hci_cmd_work+0x98/0x110
 process_one_work+0x134/0x330
 worker_thread+0x130/0x468
 kthread+0xf8/0x128
 ret_from_fork+0x10/0x18

Link: https://lkml.org/lkml/2017/11/15/908
Reported-and-tested-by: John Stultz &lt;john.stultz@linaro.org&gt;
Cc: Ronald Tschalär &lt;ronald@innovation.ch&gt;
Cc: Rob Herring &lt;rob.herring@linaro.org&gt;
Cc: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Signed-off-by: Lukas Wunner &lt;lukas@wunner.de&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: Use bt_dev_err and bt_dev_info when possible</title>
<updated>2017-10-30T10:25:45Z</updated>
<author>
<name>Marcel Holtmann</name>
</author>
<published>2017-10-30T09:42:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2064ee332e4c1b7495cf68b84355c213d8fe71fd'/>
<id>urn:sha1:2064ee332e4c1b7495cf68b84355c213d8fe71fd</id>
<content type='text'>
In case of using BT_ERR and BT_INFO, convert to bt_dev_err and
bt_dev_info when possible. This allows for controller specific
reporting.

Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Signed-off-by: Johan Hedberg &lt;johan.hedberg@intel.com&gt;
</content>
</entry>
</feed>
