From: Gustavo F. Padovan Date: Sat, 1 May 2010 19:15:45 +0000 (-0300) Subject: Bluetooth: Fix race condition on l2cap_ertm_send() X-Git-Tag: v2.6.35-rc1~473^2~179 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfc909befbfe967bd7f46ef33b6969c1b7f3cf42;p=pandora-kernel.git Bluetooth: Fix race condition on l2cap_ertm_send() l2cap_ertm_send() can be called both from user context and bottom half context. The socket locks for that contexts are different, the user context uses a mutex(which can sleep) and the second one uses a spinlock_bh. That creates a race condition when we have interruptions on both contexts at the same time. The better way to solve this is to add a new spinlock to lock l2cap_ertm_send() and the vars it access. The other solution was to defer l2cap_ertm_send() with a workqueue, but we the sending process already has one defer on the hci layer. It's not a good idea add another one. The patch refactor the code to create l2cap_retransmit_frames(), then we encapulate the lock of l2cap_ertm_send() for some call. It also changes l2cap_retransmit_frame() to l2cap_retransmit_one_frame() to avoid confusion Signed-off-by: Gustavo F. Padovan Reviewed-by: João Paulo Rechi Vita Signed-off-by: Marcel Holtmann --- Reading git-diff-tree failed