alistair23-linux/include/net/bluetooth
David Herrmann 8d12356f33 Bluetooth: introduce hci_conn ref-counting
We currently do not allow using hci_conn from outside of HCI-core.
However, several other users could make great use of it. This includes
HIDP, rfcomm and all other sub-protocols that rely on an active
connection.

Hence, we now introduce hci_conn ref-counting. We currently never call
get_device(). put_device() is exclusively used in hci_conn_del_sysfs().
Hence, we currently never have a greater device-refcnt than 1.
Therefore, it is safe to move the put_device() call from
hci_conn_del_sysfs() to hci_conn_del() (it's the only caller). In fact,
this even fixes a "use-after-free" bug as we access hci_conn after calling
hci_conn_del_sysfs() in hci_conn_del().

From now on we can add references to hci_conn objects in other layers
(like l2cap_sock, HIDP, rfcomm, ...) and grab a reference via
hci_conn_get(). This does _not_ guarantee, that the connection is still
alive. But, this isn't what we want. We can simply lock the hci_conn
device and use "device_is_registered(hci_conn->dev)" to test that.
However, this is hardly necessary as outside users should never rely on
the HCI connection to be alive, anyway. Instead, they should solely rely
on the device-object to be available.
But if sub-devices want the hci_conn object as sysfs parent, they need to
be notified when the connection drops. This will be introduced in later
patches with l2cap_users.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
2013-04-17 02:45:22 -03:00
..
a2mp.h Bluetooth: AMP: Use set_bit / test_bit for amp_mgr state 2013-01-09 17:05:05 -02:00
amp.h Bluetooth: AMP: Use l2cap_physical_cfm in phylink complete evt 2012-11-01 20:27:10 -02:00
bluetooth.h Bluetooth: Add support for custom event terminated commands 2013-04-04 19:16:08 +03:00
hci.h Bluetooth: Add reading of page scan parameters 2013-03-18 15:35:02 -03:00
hci_core.h Bluetooth: introduce hci_conn ref-counting 2013-04-17 02:45:22 -03:00
hci_mon.h Bluetooth: Fix coding style in all .h files 2012-03-07 00:04:25 -03:00
l2cap.h Bluetooth: hidp: verify l2cap sockets 2013-04-05 23:44:14 -03:00
mgmt.h Bluetooth: mgmt: Implement support for passkey notification 2012-09-18 22:27:29 -03:00
rfcomm.h Bluetooth: Remove RFCOMM session refcnt 2013-03-08 10:40:24 -03:00
sco.h Bluetooth: clean up legal text 2010-12-01 21:04:43 -02:00
smp.h Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless 2012-09-07 15:07:55 -04:00