linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>
To: "Gustavo F. Padovan" <gustavo@las.ic.unicamp.br>
Cc: linux-bluetooth@vger.kernel.org, marcel@holtmann.org,
	gustavo@padovan.org
Subject: Re: [PATCH 1/2] Bluetooth: Add locking scheme to timeout callbacks.
Date: Mon, 14 Dec 2009 12:36:21 +0200	[thread overview]
Message-ID: <508e92ca0912140236t2c93a8a1q3aae97cf9e7bdfd@mail.gmail.com> (raw)
In-Reply-To: <1251085520-9094-1-git-send-email-gustavo@las.ic.unicamp.br>

[-- Attachment #1: Type: text/plain, Size: 1563 bytes --]

Hi,

On Mon, Aug 24, 2009 at 5:45 AM, Gustavo F. Padovan
<gustavo@las.ic.unicamp.br> wrote:
> Avoid race conditions when acessing the sock.
>
> Signed-off-by: Gustavo F. Padovan <gustavo@las.ic.unicamp.br>
> ---
>  net/bluetooth/l2cap.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
> index c04526f..efac637 100644
> --- a/net/bluetooth/l2cap.c
> +++ b/net/bluetooth/l2cap.c
> @@ -1192,6 +1192,7 @@ static void l2cap_monitor_timeout(unsigned long arg)
>        struct sock *sk = (void *) arg;
>        u16 control;
>
> +       bh_lock_sock(sk);
>        if (l2cap_pi(sk)->retry_count >= l2cap_pi(sk)->remote_max_tx) {
>                l2cap_send_disconn_req(l2cap_pi(sk)->conn, sk);

missing unlock ?

>                return;
> @@ -1203,6 +1204,7 @@ static void l2cap_monitor_timeout(unsigned long arg)
>        control = L2CAP_CTRL_POLL;
>        control |= L2CAP_SUPER_RCV_READY;
>        l2cap_send_sframe(l2cap_pi(sk), control);
> +       bh_unlock_sock(sk);
>  }

Please consider following patch:

--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -1208,6 +1208,7 @@ static void l2cap_monitor_timeout(unsigned long arg)
        bh_lock_sock(sk);
        if (l2cap_pi(sk)->retry_count >= l2cap_pi(sk)->remote_max_tx) {
                l2cap_send_disconn_req(l2cap_pi(sk)->conn, sk);
+               bh_unlock_sock(sk);
                return;
        }


Also see complete patch attached.

Regards,
Andrei Emeltchenko

[-- Attachment #2: 0001-Bluetooth-Fix-locking-scheme-regression.patch.gz --]
[-- Type: application/x-gzip, Size: 600 bytes --]

  parent reply	other threads:[~2009-12-14 10:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-24  3:45 [PATCH 1/2] Bluetooth: Add locking scheme to timeout callbacks Gustavo F. Padovan
2009-08-24  3:45 ` [PATCH 2/2] Bluetooth: Use *_unaligned_le{16,32} Gustavo F. Padovan
2009-12-14 10:36 ` Andrei Emeltchenko [this message]
2009-12-14 14:13   ` [PATCH 1/2] Bluetooth: Add locking scheme to timeout callbacks Gustavo F. Padovan
2009-12-14 17:53   ` Marcel Holtmann
2009-12-15  8:03     ` Andrei Emeltchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=508e92ca0912140236t2c93a8a1q3aae97cf9e7bdfd@mail.gmail.com \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=gustavo@las.ic.unicamp.br \
    --cc=gustavo@padovan.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).