<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/net/bluetooth/sco.c, branch v3.9-rc2</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>hlist: drop the node parameter from iterators</title>
<updated>2013-02-28T03:10:24+00:00</updated>
<author>
<name>Sasha Levin</name>
<email>sasha.levin@oracle.com</email>
</author>
<published>2013-02-28T01:06:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=b67bfe0d42cac56c512dd5da4b1b347a23f4b70a'/>
<id>b67bfe0d42cac56c512dd5da4b1b347a23f4b70a</id>
<content type='text'>
I'm not sure why, but the hlist for each entry iterators were conceived

        list_for_each_entry(pos, head, member)

The hlist ones were greedy and wanted an extra parameter:

        hlist_for_each_entry(tpos, pos, head, member)

Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.

Besides the semantic patch, there was some manual work required:

 - Fix up the actual hlist iterators in linux/list.h
 - Fix up the declaration of other iterators based on the hlist ones.
 - A very small amount of places were using the 'node' parameter, this
 was modified to use 'obj-&gt;member' instead.
 - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
 properly, so those had to be fixed up manually.

The semantic patch which is mostly the work of Peter Senna Tschudin is here:

@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;

type T;
expression a,c,d,e;
identifier b;
statement S;
@@

-T b;
    &lt;+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
    ...+&gt;

[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin &lt;peter.senna@gmail.com&gt;
Acked-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Signed-off-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
Cc: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
Cc: Marcelo Tosatti &lt;mtosatti@redhat.com&gt;
Cc: Gleb Natapov &lt;gleb@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I'm not sure why, but the hlist for each entry iterators were conceived

        list_for_each_entry(pos, head, member)

The hlist ones were greedy and wanted an extra parameter:

        hlist_for_each_entry(tpos, pos, head, member)

Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.

Besides the semantic patch, there was some manual work required:

 - Fix up the actual hlist iterators in linux/list.h
 - Fix up the declaration of other iterators based on the hlist ones.
 - A very small amount of places were using the 'node' parameter, this
 was modified to use 'obj-&gt;member' instead.
 - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
 properly, so those had to be fixed up manually.

The semantic patch which is mostly the work of Peter Senna Tschudin is here:

@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;

type T;
expression a,c,d,e;
identifier b;
statement S;
@@

-T b;
    &lt;+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
    ...+&gt;

[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin &lt;peter.senna@gmail.com&gt;
Acked-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Signed-off-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
Cc: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
Cc: Marcelo Tosatti &lt;mtosatti@redhat.com&gt;
Cc: Gleb Natapov &lt;gleb@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Reduce critical section in sco_conn_ready</title>
<updated>2013-02-01T17:50:18+00:00</updated>
<author>
<name>Andre Guedes</name>
<email>andre.guedes@openbossa.org</email>
</author>
<published>2013-01-29T22:59:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=405280887f8fb4e168a1bbc865917bb2b881db95'/>
<id>405280887f8fb4e168a1bbc865917bb2b881db95</id>
<content type='text'>
This patch reduces the critical section protected by sco_conn_lock in
sco_conn_ready function. The lock is acquired only when it is really
needed.

This patch fixes the following lockdep warning which is generated
when the host terminates a SCO connection.

Today, this warning is a false positive. There is no way those
two threads reported by lockdep are running at the same time since
hdev-&gt;workqueue (where rx_work is queued) is single-thread. However,
if somehow this behavior is changed in future, we will have a
potential deadlock.

======================================================
[ INFO: possible circular locking dependency detected ]
3.8.0-rc1+ #7 Not tainted
-------------------------------------------------------
kworker/u:1H/1018 is trying to acquire lock:
 (&amp;(&amp;conn-&gt;lock)-&gt;rlock){+.+...}, at: [&lt;ffffffffa0033ba6&gt;] sco_chan_del+0x66/0x190 [bluetooth]

but task is already holding lock:
 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.+...}, at: [&lt;ffffffffa0033d5a&gt;] sco_conn_del+0x8a/0xe0 [bluetooth]

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-&gt; #1 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.+...}:
       [&lt;ffffffff81083011&gt;] lock_acquire+0xb1/0xe0
       [&lt;ffffffff813efd01&gt;] _raw_spin_lock+0x41/0x80
       [&lt;ffffffffa003436e&gt;] sco_connect_cfm+0xbe/0x350 [bluetooth]
       [&lt;ffffffffa0015d6c&gt;] hci_event_packet+0xd3c/0x29b0 [bluetooth]
       [&lt;ffffffffa0004583&gt;] hci_rx_work+0x133/0x870 [bluetooth]
       [&lt;ffffffff8104d65f&gt;] process_one_work+0x2bf/0x4f0
       [&lt;ffffffff81050022&gt;] worker_thread+0x2b2/0x3e0
       [&lt;ffffffff81056021&gt;] kthread+0xd1/0xe0
       [&lt;ffffffff813f14bc&gt;] ret_from_fork+0x7c/0xb0

-&gt; #0 (&amp;(&amp;conn-&gt;lock)-&gt;rlock){+.+...}:
       [&lt;ffffffff81082215&gt;] __lock_acquire+0x1465/0x1c70
       [&lt;ffffffff81083011&gt;] lock_acquire+0xb1/0xe0
       [&lt;ffffffff813efd01&gt;] _raw_spin_lock+0x41/0x80
       [&lt;ffffffffa0033ba6&gt;] sco_chan_del+0x66/0x190 [bluetooth]
       [&lt;ffffffffa0033d6d&gt;] sco_conn_del+0x9d/0xe0 [bluetooth]
       [&lt;ffffffffa0034653&gt;] sco_disconn_cfm+0x53/0x60 [bluetooth]
       [&lt;ffffffffa000fef3&gt;] hci_disconn_complete_evt.isra.54+0x363/0x3c0 [bluetooth]
       [&lt;ffffffffa00150f7&gt;] hci_event_packet+0xc7/0x29b0 [bluetooth]
       [&lt;ffffffffa0004583&gt;] hci_rx_work+0x133/0x870 [bluetooth]
       [&lt;ffffffff8104d65f&gt;] process_one_work+0x2bf/0x4f0
       [&lt;ffffffff81050022&gt;] worker_thread+0x2b2/0x3e0
       [&lt;ffffffff81056021&gt;] kthread+0xd1/0xe0
       [&lt;ffffffff813f14bc&gt;] ret_from_fork+0x7c/0xb0

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(slock-AF_BLUETOOTH-BTPROTO_SCO);
                               lock(&amp;(&amp;conn-&gt;lock)-&gt;rlock);
                               lock(slock-AF_BLUETOOTH-BTPROTO_SCO);
  lock(&amp;(&amp;conn-&gt;lock)-&gt;rlock);

 *** DEADLOCK ***

4 locks held by kworker/u:1H/1018:
 #0:  (hdev-&gt;name#2){.+.+.+}, at: [&lt;ffffffff8104d5f8&gt;] process_one_work+0x258/0x4f0
 #1:  ((&amp;hdev-&gt;rx_work)){+.+.+.}, at: [&lt;ffffffff8104d5f8&gt;] process_one_work+0x258/0x4f0
 #2:  (&amp;hdev-&gt;lock){+.+.+.}, at: [&lt;ffffffffa000fbe9&gt;] hci_disconn_complete_evt.isra.54+0x59/0x3c0 [bluetooth]
 #3:  (slock-AF_BLUETOOTH-BTPROTO_SCO){+.+...}, at: [&lt;ffffffffa0033d5a&gt;] sco_conn_del+0x8a/0xe0 [bluetooth]

stack backtrace:
Pid: 1018, comm: kworker/u:1H Not tainted 3.8.0-rc1+ #7
Call Trace:
 [&lt;ffffffff813e92f9&gt;] print_circular_bug+0x1fb/0x20c
 [&lt;ffffffff81082215&gt;] __lock_acquire+0x1465/0x1c70
 [&lt;ffffffff81083011&gt;] lock_acquire+0xb1/0xe0
 [&lt;ffffffffa0033ba6&gt;] ? sco_chan_del+0x66/0x190 [bluetooth]
 [&lt;ffffffff813efd01&gt;] _raw_spin_lock+0x41/0x80
 [&lt;ffffffffa0033ba6&gt;] ? sco_chan_del+0x66/0x190 [bluetooth]
 [&lt;ffffffffa0033ba6&gt;] sco_chan_del+0x66/0x190 [bluetooth]
 [&lt;ffffffffa0033d6d&gt;] sco_conn_del+0x9d/0xe0 [bluetooth]
 [&lt;ffffffffa0034653&gt;] sco_disconn_cfm+0x53/0x60 [bluetooth]
 [&lt;ffffffffa000fef3&gt;] hci_disconn_complete_evt.isra.54+0x363/0x3c0 [bluetooth]
 [&lt;ffffffffa000fbd0&gt;] ? hci_disconn_complete_evt.isra.54+0x40/0x3c0 [bluetooth]
 [&lt;ffffffffa00150f7&gt;] hci_event_packet+0xc7/0x29b0 [bluetooth]
 [&lt;ffffffff81202e90&gt;] ? __dynamic_pr_debug+0x80/0x90
 [&lt;ffffffff8133ff7d&gt;] ? kfree_skb+0x2d/0x40
 [&lt;ffffffffa0021644&gt;] ? hci_send_to_monitor+0x1a4/0x1c0 [bluetooth]
 [&lt;ffffffffa0004583&gt;] hci_rx_work+0x133/0x870 [bluetooth]
 [&lt;ffffffff8104d5f8&gt;] ? process_one_work+0x258/0x4f0
 [&lt;ffffffff8104d65f&gt;] process_one_work+0x2bf/0x4f0
 [&lt;ffffffff8104d5f8&gt;] ? process_one_work+0x258/0x4f0
 [&lt;ffffffff8104fdc1&gt;] ? worker_thread+0x51/0x3e0
 [&lt;ffffffffa0004450&gt;] ? hci_tx_work+0x800/0x800 [bluetooth]
 [&lt;ffffffff81050022&gt;] worker_thread+0x2b2/0x3e0
 [&lt;ffffffff8104fd70&gt;] ? busy_worker_rebind_fn+0x100/0x100
 [&lt;ffffffff81056021&gt;] kthread+0xd1/0xe0
 [&lt;ffffffff81055f50&gt;] ? flush_kthread_worker+0xc0/0xc0
 [&lt;ffffffff813f14bc&gt;] ret_from_fork+0x7c/0xb0
 [&lt;ffffffff81055f50&gt;] ? flush_kthread_worker+0xc0/0xc0

Signed-off-by: Andre Guedes &lt;andre.guedes@openbossa.org&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch reduces the critical section protected by sco_conn_lock in
sco_conn_ready function. The lock is acquired only when it is really
needed.

This patch fixes the following lockdep warning which is generated
when the host terminates a SCO connection.

Today, this warning is a false positive. There is no way those
two threads reported by lockdep are running at the same time since
hdev-&gt;workqueue (where rx_work is queued) is single-thread. However,
if somehow this behavior is changed in future, we will have a
potential deadlock.

======================================================
[ INFO: possible circular locking dependency detected ]
3.8.0-rc1+ #7 Not tainted
-------------------------------------------------------
kworker/u:1H/1018 is trying to acquire lock:
 (&amp;(&amp;conn-&gt;lock)-&gt;rlock){+.+...}, at: [&lt;ffffffffa0033ba6&gt;] sco_chan_del+0x66/0x190 [bluetooth]

but task is already holding lock:
 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.+...}, at: [&lt;ffffffffa0033d5a&gt;] sco_conn_del+0x8a/0xe0 [bluetooth]

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-&gt; #1 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.+...}:
       [&lt;ffffffff81083011&gt;] lock_acquire+0xb1/0xe0
       [&lt;ffffffff813efd01&gt;] _raw_spin_lock+0x41/0x80
       [&lt;ffffffffa003436e&gt;] sco_connect_cfm+0xbe/0x350 [bluetooth]
       [&lt;ffffffffa0015d6c&gt;] hci_event_packet+0xd3c/0x29b0 [bluetooth]
       [&lt;ffffffffa0004583&gt;] hci_rx_work+0x133/0x870 [bluetooth]
       [&lt;ffffffff8104d65f&gt;] process_one_work+0x2bf/0x4f0
       [&lt;ffffffff81050022&gt;] worker_thread+0x2b2/0x3e0
       [&lt;ffffffff81056021&gt;] kthread+0xd1/0xe0
       [&lt;ffffffff813f14bc&gt;] ret_from_fork+0x7c/0xb0

-&gt; #0 (&amp;(&amp;conn-&gt;lock)-&gt;rlock){+.+...}:
       [&lt;ffffffff81082215&gt;] __lock_acquire+0x1465/0x1c70
       [&lt;ffffffff81083011&gt;] lock_acquire+0xb1/0xe0
       [&lt;ffffffff813efd01&gt;] _raw_spin_lock+0x41/0x80
       [&lt;ffffffffa0033ba6&gt;] sco_chan_del+0x66/0x190 [bluetooth]
       [&lt;ffffffffa0033d6d&gt;] sco_conn_del+0x9d/0xe0 [bluetooth]
       [&lt;ffffffffa0034653&gt;] sco_disconn_cfm+0x53/0x60 [bluetooth]
       [&lt;ffffffffa000fef3&gt;] hci_disconn_complete_evt.isra.54+0x363/0x3c0 [bluetooth]
       [&lt;ffffffffa00150f7&gt;] hci_event_packet+0xc7/0x29b0 [bluetooth]
       [&lt;ffffffffa0004583&gt;] hci_rx_work+0x133/0x870 [bluetooth]
       [&lt;ffffffff8104d65f&gt;] process_one_work+0x2bf/0x4f0
       [&lt;ffffffff81050022&gt;] worker_thread+0x2b2/0x3e0
       [&lt;ffffffff81056021&gt;] kthread+0xd1/0xe0
       [&lt;ffffffff813f14bc&gt;] ret_from_fork+0x7c/0xb0

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(slock-AF_BLUETOOTH-BTPROTO_SCO);
                               lock(&amp;(&amp;conn-&gt;lock)-&gt;rlock);
                               lock(slock-AF_BLUETOOTH-BTPROTO_SCO);
  lock(&amp;(&amp;conn-&gt;lock)-&gt;rlock);

 *** DEADLOCK ***

4 locks held by kworker/u:1H/1018:
 #0:  (hdev-&gt;name#2){.+.+.+}, at: [&lt;ffffffff8104d5f8&gt;] process_one_work+0x258/0x4f0
 #1:  ((&amp;hdev-&gt;rx_work)){+.+.+.}, at: [&lt;ffffffff8104d5f8&gt;] process_one_work+0x258/0x4f0
 #2:  (&amp;hdev-&gt;lock){+.+.+.}, at: [&lt;ffffffffa000fbe9&gt;] hci_disconn_complete_evt.isra.54+0x59/0x3c0 [bluetooth]
 #3:  (slock-AF_BLUETOOTH-BTPROTO_SCO){+.+...}, at: [&lt;ffffffffa0033d5a&gt;] sco_conn_del+0x8a/0xe0 [bluetooth]

stack backtrace:
Pid: 1018, comm: kworker/u:1H Not tainted 3.8.0-rc1+ #7
Call Trace:
 [&lt;ffffffff813e92f9&gt;] print_circular_bug+0x1fb/0x20c
 [&lt;ffffffff81082215&gt;] __lock_acquire+0x1465/0x1c70
 [&lt;ffffffff81083011&gt;] lock_acquire+0xb1/0xe0
 [&lt;ffffffffa0033ba6&gt;] ? sco_chan_del+0x66/0x190 [bluetooth]
 [&lt;ffffffff813efd01&gt;] _raw_spin_lock+0x41/0x80
 [&lt;ffffffffa0033ba6&gt;] ? sco_chan_del+0x66/0x190 [bluetooth]
 [&lt;ffffffffa0033ba6&gt;] sco_chan_del+0x66/0x190 [bluetooth]
 [&lt;ffffffffa0033d6d&gt;] sco_conn_del+0x9d/0xe0 [bluetooth]
 [&lt;ffffffffa0034653&gt;] sco_disconn_cfm+0x53/0x60 [bluetooth]
 [&lt;ffffffffa000fef3&gt;] hci_disconn_complete_evt.isra.54+0x363/0x3c0 [bluetooth]
 [&lt;ffffffffa000fbd0&gt;] ? hci_disconn_complete_evt.isra.54+0x40/0x3c0 [bluetooth]
 [&lt;ffffffffa00150f7&gt;] hci_event_packet+0xc7/0x29b0 [bluetooth]
 [&lt;ffffffff81202e90&gt;] ? __dynamic_pr_debug+0x80/0x90
 [&lt;ffffffff8133ff7d&gt;] ? kfree_skb+0x2d/0x40
 [&lt;ffffffffa0021644&gt;] ? hci_send_to_monitor+0x1a4/0x1c0 [bluetooth]
 [&lt;ffffffffa0004583&gt;] hci_rx_work+0x133/0x870 [bluetooth]
 [&lt;ffffffff8104d5f8&gt;] ? process_one_work+0x258/0x4f0
 [&lt;ffffffff8104d65f&gt;] process_one_work+0x2bf/0x4f0
 [&lt;ffffffff8104d5f8&gt;] ? process_one_work+0x258/0x4f0
 [&lt;ffffffff8104fdc1&gt;] ? worker_thread+0x51/0x3e0
 [&lt;ffffffffa0004450&gt;] ? hci_tx_work+0x800/0x800 [bluetooth]
 [&lt;ffffffff81050022&gt;] worker_thread+0x2b2/0x3e0
 [&lt;ffffffff8104fd70&gt;] ? busy_worker_rebind_fn+0x100/0x100
 [&lt;ffffffff81056021&gt;] kthread+0xd1/0xe0
 [&lt;ffffffff81055f50&gt;] ? flush_kthread_worker+0xc0/0xc0
 [&lt;ffffffff813f14bc&gt;] ret_from_fork+0x7c/0xb0
 [&lt;ffffffff81055f50&gt;] ? flush_kthread_worker+0xc0/0xc0

Signed-off-by: Andre Guedes &lt;andre.guedes@openbossa.org&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Check if the hci connection exists in SCO shutdown</title>
<updated>2013-01-10T05:53:32+00:00</updated>
<author>
<name>Gustavo Padovan</name>
<email>gustavo.padovan@collabora.co.uk</email>
</author>
<published>2013-01-03T21:59:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=b7e98b5100aad9290d7f06fcb9d1e80f7f62f05f'/>
<id>b7e98b5100aad9290d7f06fcb9d1e80f7f62f05f</id>
<content type='text'>
Checking only for sco_conn seems to not be enough and lead to NULL
dereferences in the code, check for hcon instead.

&lt;1&gt;[11340.226404] BUG: unable to handle kernel NULL pointer dereference at
0000000
8
&lt;4&gt;[11340.226619] EIP is at __sco_sock_close+0xe8/0x1a0
&lt;4&gt;[11340.226629] EAX: f063a740 EBX: 00000000 ECX: f58f4544 EDX: 00000000
&lt;4&gt;[11340.226640] ESI: dec83e00 EDI: 5f9a081f EBP: e0fdff38 ESP: e0fdff1c
&lt;0&gt;[11340.226674] Stack:
&lt;4&gt;[11340.226682]  c184db87 c1251028 dec83e00 e0fdff38 c1754aef dec83e00
00000000
e0fdff5c
&lt;4&gt;[11340.226718]  c184f587 e0fdff64 e0fdff68 5f9a081f e0fdff5c c1751852
d7813800
62262f10
&lt;4&gt;[11340.226752]  e0fdff70 c1753c00 00000000 00000001 0000000d e0fdffac
c175425c
00000041
&lt;0&gt;[11340.226793] Call Trace:
&lt;4&gt;[11340.226813]  [&lt;c184db87&gt;] ? sco_sock_clear_timer+0x27/0x60
&lt;4&gt;[11340.226831]  [&lt;c1251028&gt;] ? local_bh_enable+0x68/0xd0
&lt;4&gt;[11340.226846]  [&lt;c1754aef&gt;] ? lock_sock_nested+0x4f/0x60
&lt;4&gt;[11340.226862]  [&lt;c184f587&gt;] sco_sock_shutdown+0x67/0xb0
&lt;4&gt;[11340.226879]  [&lt;c1751852&gt;] ? sockfd_lookup_light+0x22/0x80
&lt;4&gt;[11340.226897]  [&lt;c1753c00&gt;] sys_shutdown+0x30/0x60
&lt;4&gt;[11340.226912]  [&lt;c175425c&gt;] sys_socketcall+0x1dc/0x2a0
&lt;4&gt;[11340.226929]  [&lt;c149ba78&gt;] ? trace_hardirqs_on_thunk+0xc/0x10
&lt;4&gt;[11340.226944]  [&lt;c18860f1&gt;] syscall_call+0x7/0xb
&lt;4&gt;[11340.226960]  [&lt;c1880000&gt;] ? restore_cur+0x5e/0xd7
&lt;0&gt;[11340.226969] Code: &lt;f0&gt; ff 4b 08 0f 94 c0 84 c0 74 20 80 7b 19 01 74
2f b8 0a 00 00

Reported-by: Chuansheng Liu &lt;chuansheng.liu@intel.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Checking only for sco_conn seems to not be enough and lead to NULL
dereferences in the code, check for hcon instead.

&lt;1&gt;[11340.226404] BUG: unable to handle kernel NULL pointer dereference at
0000000
8
&lt;4&gt;[11340.226619] EIP is at __sco_sock_close+0xe8/0x1a0
&lt;4&gt;[11340.226629] EAX: f063a740 EBX: 00000000 ECX: f58f4544 EDX: 00000000
&lt;4&gt;[11340.226640] ESI: dec83e00 EDI: 5f9a081f EBP: e0fdff38 ESP: e0fdff1c
&lt;0&gt;[11340.226674] Stack:
&lt;4&gt;[11340.226682]  c184db87 c1251028 dec83e00 e0fdff38 c1754aef dec83e00
00000000
e0fdff5c
&lt;4&gt;[11340.226718]  c184f587 e0fdff64 e0fdff68 5f9a081f e0fdff5c c1751852
d7813800
62262f10
&lt;4&gt;[11340.226752]  e0fdff70 c1753c00 00000000 00000001 0000000d e0fdffac
c175425c
00000041
&lt;0&gt;[11340.226793] Call Trace:
&lt;4&gt;[11340.226813]  [&lt;c184db87&gt;] ? sco_sock_clear_timer+0x27/0x60
&lt;4&gt;[11340.226831]  [&lt;c1251028&gt;] ? local_bh_enable+0x68/0xd0
&lt;4&gt;[11340.226846]  [&lt;c1754aef&gt;] ? lock_sock_nested+0x4f/0x60
&lt;4&gt;[11340.226862]  [&lt;c184f587&gt;] sco_sock_shutdown+0x67/0xb0
&lt;4&gt;[11340.226879]  [&lt;c1751852&gt;] ? sockfd_lookup_light+0x22/0x80
&lt;4&gt;[11340.226897]  [&lt;c1753c00&gt;] sys_shutdown+0x30/0x60
&lt;4&gt;[11340.226912]  [&lt;c175425c&gt;] sys_socketcall+0x1dc/0x2a0
&lt;4&gt;[11340.226929]  [&lt;c149ba78&gt;] ? trace_hardirqs_on_thunk+0xc/0x10
&lt;4&gt;[11340.226944]  [&lt;c18860f1&gt;] syscall_call+0x7/0xb
&lt;4&gt;[11340.226960]  [&lt;c1880000&gt;] ? restore_cur+0x5e/0xd7
&lt;0&gt;[11340.226969] Code: &lt;f0&gt; ff 4b 08 0f 94 c0 84 c0 74 20 80 7b 19 01 74
2f b8 0a 00 00

Reported-by: Chuansheng Liu &lt;chuansheng.liu@intel.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "Bluetooth: Fix possible deadlock in SCO code"</title>
<updated>2012-12-03T18:00:04+00:00</updated>
<author>
<name>Gustavo Padovan</name>
<email>gustavo.padovan@collabora.co.uk</email>
</author>
<published>2012-12-03T17:36:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0b27a4b97cb1874503c78453c0903df53c0c86b2'/>
<id>0b27a4b97cb1874503c78453c0903df53c0c86b2</id>
<content type='text'>
This reverts commit 269c4845d5b3627b95b1934107251bacbe99bb68.

The commit was causing dead locks and NULL dereferences in the sco code:

 [28084.104013] BUG: soft lockup - CPU#0 stuck for 22s! [kworker/u:0H:7]
 [28084.104021] Modules linked in: btusb bluetooth &lt;snip [last unloaded:
bluetooth]
...
 [28084.104021]  [&lt;c160246d&gt;] _raw_spin_lock+0xd/0x10
 [28084.104021]  [&lt;f920e708&gt;] sco_conn_del+0x58/0x1b0 [bluetooth]
 [28084.104021]  [&lt;f920f1a9&gt;] sco_connect_cfm+0xb9/0x2b0 [bluetooth]
 [28084.104021]  [&lt;f91ef289&gt;]
hci_sync_conn_complete_evt.isra.94+0x1c9/0x260 [bluetooth]
 [28084.104021]  [&lt;f91f1a8d&gt;] hci_event_packet+0x74d/0x2b40 [bluetooth]
 [28084.104021]  [&lt;c1501abd&gt;] ? __kfree_skb+0x3d/0x90
 [28084.104021]  [&lt;c1501b46&gt;] ? kfree_skb+0x36/0x90
 [28084.104021]  [&lt;f91fcb4e&gt;] ? hci_send_to_monitor+0x10e/0x190 [bluetooth]
 [28084.104021]  [&lt;f91fcb4e&gt;] ? hci_send_to_monitor+0x10e/0x190 [bluetooth]

Cc: stable@vger.kernel.org
Reported-by: Chan-yeol Park &lt;chanyeol.park@gmail.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit 269c4845d5b3627b95b1934107251bacbe99bb68.

The commit was causing dead locks and NULL dereferences in the sco code:

 [28084.104013] BUG: soft lockup - CPU#0 stuck for 22s! [kworker/u:0H:7]
 [28084.104021] Modules linked in: btusb bluetooth &lt;snip [last unloaded:
bluetooth]
...
 [28084.104021]  [&lt;c160246d&gt;] _raw_spin_lock+0xd/0x10
 [28084.104021]  [&lt;f920e708&gt;] sco_conn_del+0x58/0x1b0 [bluetooth]
 [28084.104021]  [&lt;f920f1a9&gt;] sco_connect_cfm+0xb9/0x2b0 [bluetooth]
 [28084.104021]  [&lt;f91ef289&gt;]
hci_sync_conn_complete_evt.isra.94+0x1c9/0x260 [bluetooth]
 [28084.104021]  [&lt;f91f1a8d&gt;] hci_event_packet+0x74d/0x2b40 [bluetooth]
 [28084.104021]  [&lt;c1501abd&gt;] ? __kfree_skb+0x3d/0x90
 [28084.104021]  [&lt;c1501b46&gt;] ? kfree_skb+0x36/0x90
 [28084.104021]  [&lt;f91fcb4e&gt;] ? hci_send_to_monitor+0x10e/0x190 [bluetooth]
 [28084.104021]  [&lt;f91fcb4e&gt;] ? hci_send_to_monitor+0x10e/0x190 [bluetooth]

Cc: stable@vger.kernel.org
Reported-by: Chan-yeol Park &lt;chanyeol.park@gmail.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Implement deferred sco socket setup</title>
<updated>2012-12-03T17:59:58+00:00</updated>
<author>
<name>Frédéric Dalleau</name>
<email>frederic.dalleau@linux.intel.com</email>
</author>
<published>2012-11-21T09:51:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=20714bfef84d3e690c9c6f8e9cd46543b5ae1eed'/>
<id>20714bfef84d3e690c9c6f8e9cd46543b5ae1eed</id>
<content type='text'>
In order to authenticate and configure an incoming SCO connection, the
BT_DEFER_SETUP option was added. This option is intended to defer reply
to Connect Request on SCO sockets.
When a connection is requested, the listening socket is unblocked but
the effective connection setup happens only on first recv. Any send
between accept and recv fails with -ENOTCONN.

Signed-off-by: Frédéric Dalleau &lt;frederic.dalleau@linux.intel.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In order to authenticate and configure an incoming SCO connection, the
BT_DEFER_SETUP option was added. This option is intended to defer reply
to Connect Request on SCO sockets.
When a connection is requested, the listening socket is unblocked but
the effective connection setup happens only on first recv. Any send
between accept and recv fails with -ENOTCONN.

Signed-off-by: Frédéric Dalleau &lt;frederic.dalleau@linux.intel.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Add BT_DEFER_SETUP option to sco socket</title>
<updated>2012-12-03T17:59:58+00:00</updated>
<author>
<name>Frédéric Dalleau</name>
<email>frederic.dalleau@linux.intel.com</email>
</author>
<published>2012-11-21T09:51:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=b96e9c671b05f95126753a22145d4509d45ca197'/>
<id>b96e9c671b05f95126753a22145d4509d45ca197</id>
<content type='text'>
This option will set the BT_SK_DEFER_SETUP bit in socket flags.

Signed-off-by: Frédéric Dalleau &lt;frederic.dalleau@linux.intel.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This option will set the BT_SK_DEFER_SETUP bit in socket flags.

Signed-off-by: Frédéric Dalleau &lt;frederic.dalleau@linux.intel.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Use %pMR in sprintf/seq_printf instead of batostr</title>
<updated>2012-09-27T21:10:15+00:00</updated>
<author>
<name>Andrei Emeltchenko</name>
<email>andrei.emeltchenko@intel.com</email>
</author>
<published>2012-09-25T09:49:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=fcb73338ed531dcc00cb17ca76fe3e05f774e4e9'/>
<id>fcb73338ed531dcc00cb17ca76fe3e05f774e4e9</id>
<content type='text'>
Instead of old unsafe batostr function use %pMR print specifier
for printing Bluetooth addresses in sprintf and seq_printf
statements.

Signed-off-by: Andrei Emeltchenko &lt;andrei.emeltchenko@intel.com&gt;
Acked-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Instead of old unsafe batostr function use %pMR print specifier
for printing Bluetooth addresses in sprintf and seq_printf
statements.

Signed-off-by: Andrei Emeltchenko &lt;andrei.emeltchenko@intel.com&gt;
Acked-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Use %pMR in debug instead of batostr</title>
<updated>2012-09-27T21:10:00+00:00</updated>
<author>
<name>Andrei Emeltchenko</name>
<email>andrei.emeltchenko@intel.com</email>
</author>
<published>2012-09-25T09:49:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=6ed93dc6427d14cdfe0b272cc0a9ee4685ce9ad7'/>
<id>6ed93dc6427d14cdfe0b272cc0a9ee4685ce9ad7</id>
<content type='text'>
Instead of old unsafe batostr function use %pMR print specifier
for printing Bluetooth addresses in debug and error statements.

Signed-off-by: Andrei Emeltchenko &lt;andrei.emeltchenko@intel.com&gt;
Acked-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Instead of old unsafe batostr function use %pMR print specifier
for printing Bluetooth addresses in debug and error statements.

Signed-off-by: Andrei Emeltchenko &lt;andrei.emeltchenko@intel.com&gt;
Acked-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless</title>
<updated>2012-09-07T19:07:55+00:00</updated>
<author>
<name>John W. Linville</name>
<email>linville@tuxdriver.com</email>
</author>
<published>2012-09-07T19:07:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=fac805f8c198092de9a2842efd7f5022e2937b18'/>
<id>fac805f8c198092de9a2842efd7f5022e2937b18</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Bluetooth: Fix possible deadlock in SCO code</title>
<updated>2012-08-06T18:19:36+00:00</updated>
<author>
<name>Gustavo Padovan</name>
<email>gustavo.padovan@collabora.co.uk</email>
</author>
<published>2012-06-15T05:30:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=269c4845d5b3627b95b1934107251bacbe99bb68'/>
<id>269c4845d5b3627b95b1934107251bacbe99bb68</id>
<content type='text'>
sco_chan_del() only has conn != NULL when called from sco_conn_del() so
just move the code from it that deal with conn to sco_conn_del().

[  120.765529]
[  120.765529] ======================================================
[  120.766529] [ INFO: possible circular locking dependency detected ]
[  120.766529] 3.5.0-rc1-10292-g3701f94-dirty #70 Tainted: G        W
[  120.766529] -------------------------------------------------------
[  120.766529] kworker/u:3/1497 is trying to acquire lock:
[  120.766529]  (&amp;(&amp;conn-&gt;lock)-&gt;rlock#2){+.+...}, at:
[&lt;ffffffffa00b7ecc&gt;] sco_chan_del+0x4c/0x170 [bluetooth]
[  120.766529]
[  120.766529] but task is already holding lock:
[  120.766529]  (slock-AF_BLUETOOTH-BTPROTO_SCO){+.+...}, at:
[&lt;ffffffffa00b8401&gt;] sco_conn_del+0x61/0xe0 [bluetooth]
[  120.766529]
[  120.766529] which lock already depends on the new lock.
[  120.766529]
[  120.766529]
[  120.766529] the existing dependency chain (in reverse order) is:
[  120.766529]
[  120.766529] -&gt; #1 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.+...}:
[  120.766529]        [&lt;ffffffff8107980e&gt;] lock_acquire+0x8e/0xb0
[  120.766529]        [&lt;ffffffff813c19e0&gt;] _raw_spin_lock+0x40/0x80
[  120.766529]        [&lt;ffffffffa00b85e9&gt;] sco_connect_cfm+0x79/0x300
[bluetooth]
[  120.766529]        [&lt;ffffffffa0094b13&gt;]
hci_sync_conn_complete_evt.isra.90+0x343/0x400 [bluetooth]
[  120.766529]        [&lt;ffffffffa009d447&gt;] hci_event_packet+0x317/0xfb0
[bluetooth]
[  120.766529]        [&lt;ffffffffa008aa68&gt;] hci_rx_work+0x2c8/0x890
[bluetooth]
[  120.766529]        [&lt;ffffffff81047db7&gt;] process_one_work+0x197/0x460
[  120.766529]        [&lt;ffffffff810489d6&gt;] worker_thread+0x126/0x2d0
[  120.766529]        [&lt;ffffffff8104ee4d&gt;] kthread+0x9d/0xb0
[  120.766529]        [&lt;ffffffff813c4294&gt;] kernel_thread_helper+0x4/0x10
[  120.766529]
[  120.766529] -&gt; #0 (&amp;(&amp;conn-&gt;lock)-&gt;rlock#2){+.+...}:
[  120.766529]        [&lt;ffffffff81078a8a&gt;] __lock_acquire+0x154a/0x1d30
[  120.766529]        [&lt;ffffffff8107980e&gt;] lock_acquire+0x8e/0xb0
[  120.766529]        [&lt;ffffffff813c19e0&gt;] _raw_spin_lock+0x40/0x80
[  120.766529]        [&lt;ffffffffa00b7ecc&gt;] sco_chan_del+0x4c/0x170
[bluetooth]
[  120.766529]        [&lt;ffffffffa00b8414&gt;] sco_conn_del+0x74/0xe0
[bluetooth]
[  120.766529]        [&lt;ffffffffa00b88a2&gt;] sco_disconn_cfm+0x32/0x60
[bluetooth]
[  120.766529]        [&lt;ffffffffa0093a82&gt;]
hci_disconn_complete_evt.isra.53+0x242/0x390 [bluetooth]
[  120.766529]        [&lt;ffffffffa009d747&gt;] hci_event_packet+0x617/0xfb0
[bluetooth]
[  120.766529]        [&lt;ffffffffa008aa68&gt;] hci_rx_work+0x2c8/0x890
[bluetooth]
[  120.766529]        [&lt;ffffffff81047db7&gt;] process_one_work+0x197/0x460
[  120.766529]        [&lt;ffffffff810489d6&gt;] worker_thread+0x126/0x2d0
[  120.766529]        [&lt;ffffffff8104ee4d&gt;] kthread+0x9d/0xb0
[  120.766529]        [&lt;ffffffff813c4294&gt;] kernel_thread_helper+0x4/0x10
[  120.766529]
[  120.766529] other info that might help us debug this:
[  120.766529]
[  120.766529]  Possible unsafe locking scenario:
[  120.766529]
[  120.766529]        CPU0                    CPU1
[  120.766529]        ----                    ----
[  120.766529]   lock(slock-AF_BLUETOOTH-BTPROTO_SCO);
[  120.766529]
lock(&amp;(&amp;conn-&gt;lock)-&gt;rlock#2);
[  120.766529]
lock(slock-AF_BLUETOOTH-BTPROTO_SCO);
[  120.766529]   lock(&amp;(&amp;conn-&gt;lock)-&gt;rlock#2);
[  120.766529]
[  120.766529]  *** DEADLOCK ***

Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
sco_chan_del() only has conn != NULL when called from sco_conn_del() so
just move the code from it that deal with conn to sco_conn_del().

[  120.765529]
[  120.765529] ======================================================
[  120.766529] [ INFO: possible circular locking dependency detected ]
[  120.766529] 3.5.0-rc1-10292-g3701f94-dirty #70 Tainted: G        W
[  120.766529] -------------------------------------------------------
[  120.766529] kworker/u:3/1497 is trying to acquire lock:
[  120.766529]  (&amp;(&amp;conn-&gt;lock)-&gt;rlock#2){+.+...}, at:
[&lt;ffffffffa00b7ecc&gt;] sco_chan_del+0x4c/0x170 [bluetooth]
[  120.766529]
[  120.766529] but task is already holding lock:
[  120.766529]  (slock-AF_BLUETOOTH-BTPROTO_SCO){+.+...}, at:
[&lt;ffffffffa00b8401&gt;] sco_conn_del+0x61/0xe0 [bluetooth]
[  120.766529]
[  120.766529] which lock already depends on the new lock.
[  120.766529]
[  120.766529]
[  120.766529] the existing dependency chain (in reverse order) is:
[  120.766529]
[  120.766529] -&gt; #1 (slock-AF_BLUETOOTH-BTPROTO_SCO){+.+...}:
[  120.766529]        [&lt;ffffffff8107980e&gt;] lock_acquire+0x8e/0xb0
[  120.766529]        [&lt;ffffffff813c19e0&gt;] _raw_spin_lock+0x40/0x80
[  120.766529]        [&lt;ffffffffa00b85e9&gt;] sco_connect_cfm+0x79/0x300
[bluetooth]
[  120.766529]        [&lt;ffffffffa0094b13&gt;]
hci_sync_conn_complete_evt.isra.90+0x343/0x400 [bluetooth]
[  120.766529]        [&lt;ffffffffa009d447&gt;] hci_event_packet+0x317/0xfb0
[bluetooth]
[  120.766529]        [&lt;ffffffffa008aa68&gt;] hci_rx_work+0x2c8/0x890
[bluetooth]
[  120.766529]        [&lt;ffffffff81047db7&gt;] process_one_work+0x197/0x460
[  120.766529]        [&lt;ffffffff810489d6&gt;] worker_thread+0x126/0x2d0
[  120.766529]        [&lt;ffffffff8104ee4d&gt;] kthread+0x9d/0xb0
[  120.766529]        [&lt;ffffffff813c4294&gt;] kernel_thread_helper+0x4/0x10
[  120.766529]
[  120.766529] -&gt; #0 (&amp;(&amp;conn-&gt;lock)-&gt;rlock#2){+.+...}:
[  120.766529]        [&lt;ffffffff81078a8a&gt;] __lock_acquire+0x154a/0x1d30
[  120.766529]        [&lt;ffffffff8107980e&gt;] lock_acquire+0x8e/0xb0
[  120.766529]        [&lt;ffffffff813c19e0&gt;] _raw_spin_lock+0x40/0x80
[  120.766529]        [&lt;ffffffffa00b7ecc&gt;] sco_chan_del+0x4c/0x170
[bluetooth]
[  120.766529]        [&lt;ffffffffa00b8414&gt;] sco_conn_del+0x74/0xe0
[bluetooth]
[  120.766529]        [&lt;ffffffffa00b88a2&gt;] sco_disconn_cfm+0x32/0x60
[bluetooth]
[  120.766529]        [&lt;ffffffffa0093a82&gt;]
hci_disconn_complete_evt.isra.53+0x242/0x390 [bluetooth]
[  120.766529]        [&lt;ffffffffa009d747&gt;] hci_event_packet+0x617/0xfb0
[bluetooth]
[  120.766529]        [&lt;ffffffffa008aa68&gt;] hci_rx_work+0x2c8/0x890
[bluetooth]
[  120.766529]        [&lt;ffffffff81047db7&gt;] process_one_work+0x197/0x460
[  120.766529]        [&lt;ffffffff810489d6&gt;] worker_thread+0x126/0x2d0
[  120.766529]        [&lt;ffffffff8104ee4d&gt;] kthread+0x9d/0xb0
[  120.766529]        [&lt;ffffffff813c4294&gt;] kernel_thread_helper+0x4/0x10
[  120.766529]
[  120.766529] other info that might help us debug this:
[  120.766529]
[  120.766529]  Possible unsafe locking scenario:
[  120.766529]
[  120.766529]        CPU0                    CPU1
[  120.766529]        ----                    ----
[  120.766529]   lock(slock-AF_BLUETOOTH-BTPROTO_SCO);
[  120.766529]
lock(&amp;(&amp;conn-&gt;lock)-&gt;rlock#2);
[  120.766529]
lock(slock-AF_BLUETOOTH-BTPROTO_SCO);
[  120.766529]   lock(&amp;(&amp;conn-&gt;lock)-&gt;rlock#2);
[  120.766529]
[  120.766529]  *** DEADLOCK ***

Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
</pre>
</div>
</content>
</entry>
</feed>
