linux/net/bluetooth
Marcel Holtmann 64dae967ca Bluetooth: Move smp_unregister() into hci_dev_do_close() function
The smp_unregister() function needs to be called every time the
controller is powered down. There are multiple entry points when
this can happen. One is "hciconfig hci0 reset" which will throw
a WARN_ON when LE support has been enabled.

[   78.564620] WARNING: CPU: 0 PID: 148 at net/bluetooth/smp.c:3075 smp_register+0xf1/0x170()
[   78.564622] Modules linked in:
[   78.564628] CPU: 0 PID: 148 Comm: kworker/u3:1 Not tainted 3.19.0-rc4-devel+ #404
[   78.564629] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
[   78.564635] Workqueue: hci0 hci_rx_work
[   78.564638]  ffffffff81b4a7a2 ffff88001cb2fb38 ffffffff8161d881 0000000080000000
[   78.564642]  0000000000000000 ffff88001cb2fb78 ffffffff8103b870 696e55206e6f6f6d
[   78.564645]  ffff88001d965000 0000000000000000 0000000000000000 ffff88001d965000
[   78.564648] Call Trace:
[   78.564655]  [<ffffffff8161d881>] dump_stack+0x4f/0x7b
[   78.564662]  [<ffffffff8103b870>] warn_slowpath_common+0x80/0xc0
[   78.564667]  [<ffffffff81544b00>] ? add_uuid+0x1f0/0x1f0
[   78.564671]  [<ffffffff8103b955>] warn_slowpath_null+0x15/0x20
[   78.564674]  [<ffffffff81562d81>] smp_register+0xf1/0x170
[   78.564680]  [<ffffffff81081236>] ? lock_timer_base.isra.30+0x26/0x50
[   78.564683]  [<ffffffff81544bf0>] powered_complete+0xf0/0x120
[   78.564688]  [<ffffffff8152e622>] hci_req_cmd_complete+0x82/0x260
[   78.564692]  [<ffffffff8153554f>] hci_cmd_complete_evt+0x6cf/0x2e20
[   78.564697]  [<ffffffff81623e43>] ? _raw_spin_unlock_irqrestore+0x13/0x30
[   78.564701]  [<ffffffff8106b0af>] ? __wake_up_sync_key+0x4f/0x60
[   78.564705]  [<ffffffff8153a2ab>] hci_event_packet+0xbcb/0x2e70
[   78.564709]  [<ffffffff814094d3>] ? skb_release_all+0x23/0x30
[   78.564711]  [<ffffffff81409529>] ? kfree_skb+0x29/0x40
[   78.564715]  [<ffffffff815296c8>] hci_rx_work+0x1c8/0x3f0
[   78.564719]  [<ffffffff8105bd91>] ? get_parent_ip+0x11/0x50
[   78.564722]  [<ffffffff8105be25>] ? preempt_count_add+0x55/0xb0
[   78.564727]  [<ffffffff8104f65f>] process_one_work+0x12f/0x360
[   78.564731]  [<ffffffff8104ff9b>] worker_thread+0x6b/0x4b0
[   78.564735]  [<ffffffff8104ff30>] ? cancel_delayed_work_sync+0x10/0x10
[   78.564738]  [<ffffffff810542fa>] kthread+0xea/0x100
[   78.564742]  [<ffffffff81620000>] ? __schedule+0x3e0/0x980
[   78.564745]  [<ffffffff81054210>] ? kthread_create_on_node+0x180/0x180
[   78.564749]  [<ffffffff816246ec>] ret_from_fork+0x7c/0xb0
[   78.564752]  [<ffffffff81054210>] ? kthread_create_on_node+0x180/0x180
[   78.564755] ---[ end trace 8b0d943af76d3736 ]---

This warning is not critical and has only been placed in the code to
actually catch this exact situation. To avoid triggering it move
the smp_unregister() into hci_dev_do_close() which will now also
take care of remove the SMP channel. It is safe to call this function
since it only remove the channel if it has been previously registered.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2015-01-29 07:53:42 +02:00
..
bnep Bluetooth: bnep: bnep_add_connection() should verify that it's dealing with l2cap socket 2014-12-19 13:48:27 +01:00
cmtp Bluetooth: Remove dead code 2015-01-14 11:16:17 +02:00
hidp Bluetooth: hidp_connection_add() unsafe use of l2cap_pi() 2014-12-19 13:40:07 +01:00
rfcomm Bluetooth: Fix nested sleeps 2015-01-23 20:29:42 +02:00
6lowpan.c Bluetooth: 6lowpan: Remove PSM setting code 2015-01-14 22:48:13 +01:00
a2mp.c first fruits - kill l2cap ->memcpy_fromiovec() 2014-12-09 16:29:10 -05:00
a2mp.h Bluetooth: Move a2mp.h header file into net/bluetooth/ 2013-10-11 00:10:05 +02:00
af_bluetooth.c Bluetooth: Add support for self testing framework 2014-12-30 08:53:55 +02:00
amp.c Bluetooth: Fix sparse warning in amp.c 2014-11-11 00:07:29 +01:00
amp.h Bluetooth: Move amp.h header file into net/bluetooth/ 2013-10-11 00:10:03 +02:00
ecc.c Bluetooth: Add ECC library for LE Secure Connections 2014-12-03 16:51:16 +01:00
ecc.h Bluetooth: Add ECC library for LE Secure Connections 2014-12-03 16:51:16 +01:00
hci_conn.c Bluetooth: Remove unused function 2015-01-16 13:06:38 +02:00
hci_core.c Bluetooth: Move smp_unregister() into hci_dev_do_close() function 2015-01-29 07:53:42 +02:00
hci_debugfs.c Bluetooth: Fix scope of sc_only_mode debugfs entry 2015-01-02 22:22:04 +01:00
hci_debugfs.h Bluetooth: Create debugfs directory for each connection handle 2014-12-20 19:54:24 +02:00
hci_event.c Bluetooth: Perform a power cycle when receiving hardware error event 2015-01-28 21:26:24 +01:00
hci_request.c Bluetooth: Add opcode parameter to hci_req_complete_t callback 2015-01-12 11:16:31 +02:00
hci_request.h Bluetooth: Add hci_request support for hci_update_background_scan 2014-12-19 22:06:37 +01:00
hci_sock.c Bluetooth: Replace send_monitor_event with queue_monitor_skb 2015-01-12 11:26:09 +02:00
hci_sysfs.c Bluetooth: Convert to use ATTRIBUTE_GROUPS macro 2014-02-13 09:51:34 +02:00
Kconfig Bluetooth: Add skeleton for SMP self-tests 2014-12-30 08:54:33 +01:00
l2cap_core.c Bluetooth: Fix lookup of fixed channels by local bdaddr 2015-01-15 16:54:14 +01:00
l2cap_sock.c Bluetooth: Fix nested sleeps 2015-01-23 20:29:42 +02:00
lib.c Bluetooth: Convert bt_<level> logging functions to return void 2014-09-24 09:40:08 +02:00
Makefile Bluetooth: Add support for self testing framework 2014-12-30 08:53:55 +02:00
mgmt.c Bluetooth: Fix check for SSP when enabling SC 2015-01-28 21:26:22 +01:00
sco.c Bluetooth: Fix nested sleeps 2015-01-23 20:29:42 +02:00
selftest.c Bluetooth: Use %llu for printing duration details of selftests 2015-01-14 10:02:45 +02:00
selftest.h Bluetooth: Add support for self testing framework 2014-12-30 08:53:55 +02:00
smp.c Bluetooth: Add paranoid check for existing LE and BR/EDR SMP channels 2015-01-15 21:59:38 +02:00
smp.h Bluetooth: Add skeleton for SMP self-tests 2014-12-30 08:54:33 +01:00