Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 122418
b: refs/heads/master
c: db7aa1c
h: refs/heads/master
v: v3
  • Loading branch information
Marcel Holtmann committed Nov 30, 2008
1 parent f5707ef commit 41abca1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c6bf514c6e0171c5b731beffaa0c4463e2335f3d
refs/heads/master: db7aa1c203d477351ed1b8f394b40d9df06ddfc4
41 changes: 23 additions & 18 deletions trunk/net/bluetooth/af_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@
/* Bluetooth sockets */
#define BT_MAX_PROTO 8
static struct net_proto_family *bt_proto[BT_MAX_PROTO];
static DEFINE_RWLOCK(bt_proto_lock);

static struct lock_class_key bt_slock_key[BT_MAX_PROTO];
#ifdef CONFIG_DEBUG_LOCK_ALLOC
static struct lock_class_key bt_lock_key[BT_MAX_PROTO];
static const char *bt_key_strings[BT_MAX_PROTO] = {
"sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP",
Expand All @@ -65,6 +66,7 @@ static const char *bt_key_strings[BT_MAX_PROTO] = {
"sk_lock-AF_BLUETOOTH-BTPROTO_AVDTP",
};

static struct lock_class_key bt_slock_key[BT_MAX_PROTO];
static const char *bt_slock_key_strings[BT_MAX_PROTO] = {
"slock-AF_BLUETOOTH-BTPROTO_L2CAP",
"slock-AF_BLUETOOTH-BTPROTO_HCI",
Expand All @@ -75,7 +77,25 @@ static const char *bt_slock_key_strings[BT_MAX_PROTO] = {
"slock-AF_BLUETOOTH-BTPROTO_HIDP",
"slock-AF_BLUETOOTH-BTPROTO_AVDTP",
};
static DEFINE_RWLOCK(bt_proto_lock);

static inline void bt_sock_reclassify_lock(struct socket *sock, int proto)
{
struct sock *sk = sock->sk;

if (!sk)
return;

BUG_ON(sock_owned_by_user(sk));

sock_lock_init_class_and_name(sk,
bt_slock_key_strings[proto], &bt_slock_key[proto],
bt_key_strings[proto], &bt_lock_key[proto]);
}
#else
static inline void bt_sock_reclassify_lock(struct socket *sock, int proto)
{
}
#endif

int bt_sock_register(int proto, struct net_proto_family *ops)
{
Expand Down Expand Up @@ -117,21 +137,6 @@ int bt_sock_unregister(int proto)
}
EXPORT_SYMBOL(bt_sock_unregister);

static void bt_reclassify_sock_lock(struct socket *sock, int proto)
{
struct sock *sk = sock->sk;

if (!sk)
return;
BUG_ON(sock_owned_by_user(sk));

sock_lock_init_class_and_name(sk,
bt_slock_key_strings[proto],
&bt_slock_key[proto],
bt_key_strings[proto],
&bt_lock_key[proto]);
}

static int bt_sock_create(struct net *net, struct socket *sock, int proto)
{
int err;
Expand All @@ -151,7 +156,7 @@ static int bt_sock_create(struct net *net, struct socket *sock, int proto)

if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) {
err = bt_proto[proto]->create(net, sock, proto);
bt_reclassify_sock_lock(sock, proto);
bt_sock_reclassify_lock(sock, proto);
module_put(bt_proto[proto]->owner);
}

Expand Down

0 comments on commit 41abca1

Please sign in to comment.