From: Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCHv1 2/2] Bluetooth: Prevent sk freeing in tasklet using refcount
Date: Wed, 26 May 2010 17:21:34 +0300 [thread overview]
Message-ID: <1274883694-18120-3-git-send-email-Andrei.Emeltchenko.news@gmail.com> (raw)
In-Reply-To: <1274883694-18120-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
Socket sk may be freed in tasklet while still be in use in krfcommd
process. Use refcount to mark sk as used.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
---
net/bluetooth/l2cap.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 794f2b7..bf762d6 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -1724,6 +1724,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
if (msg->msg_flags & MSG_OOB)
return -EOPNOTSUPP;
+ sock_hold(sk);
lock_sock(sk);
if (sk->sk_state != BT_CONNECTED) {
@@ -1808,6 +1809,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
done:
release_sock(sk);
+ sock_put(sk);
return err;
}
--
1.7.0.4
next prev parent reply other threads:[~2010-05-26 14:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-26 14:21 [PATCHv1 0/2] Don't delete l2cap chan and sk when sk is owned by user Emeltchenko Andrei
2010-05-26 14:21 ` [PATCHv1 1/2] Bluetooth: Check sk is not owned before freeing l2cap_conn Emeltchenko Andrei
2010-07-06 15:21 ` Marcel Holtmann
2010-08-12 9:49 ` Andrei Emeltchenko
2010-08-12 11:27 ` Marcel Holtmann
2010-08-12 13:33 ` Andrei Emeltchenko
2010-05-26 14:21 ` Emeltchenko Andrei [this message]
2010-06-07 14:11 ` [PATCHv1 0/2] Don't delete l2cap chan and sk when sk is owned by user Andrei Emeltchenko
2010-07-06 10:20 ` 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=1274883694-18120-3-git-send-email-Andrei.Emeltchenko.news@gmail.com \
--to=andrei.emeltchenko.news@gmail.com \
--cc=linux-bluetooth@vger.kernel.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).