diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-10-06 22:32:29 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-10-07 00:43:17 -0400 |
commit | 81b25cd04387fbceb76fe893db4863a380941413 (patch) | |
tree | daa5a45323d8cd1cf5ce02935c9fd73daa782899 /net/bluetooth/hidp | |
parent | 1785dbf9e30be62ab45e34900e574b8307bc98b5 (diff) |
Bluetooth: Delay session allocation in hidp
It gets allocated only when it is really needed.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/hidp')
-rw-r--r-- | net/bluetooth/hidp/core.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 304a73f96cc2..fbbf80295020 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c | |||
@@ -979,18 +979,20 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, | |||
979 | bacmp(&bt_sk(ctrl_sock->sk)->dst, &bt_sk(intr_sock->sk)->dst)) | 979 | bacmp(&bt_sk(ctrl_sock->sk)->dst, &bt_sk(intr_sock->sk)->dst)) |
980 | return -ENOTUNIQ; | 980 | return -ENOTUNIQ; |
981 | 981 | ||
982 | session = kzalloc(sizeof(struct hidp_session), GFP_KERNEL); | ||
983 | if (!session) | ||
984 | return -ENOMEM; | ||
985 | |||
986 | BT_DBG("rd_data %p rd_size %d", req->rd_data, req->rd_size); | 982 | BT_DBG("rd_data %p rd_size %d", req->rd_data, req->rd_size); |
987 | 983 | ||
988 | down_write(&hidp_session_sem); | 984 | down_write(&hidp_session_sem); |
989 | 985 | ||
990 | s = __hidp_get_session(&bt_sk(ctrl_sock->sk)->dst); | 986 | s = __hidp_get_session(&bt_sk(ctrl_sock->sk)->dst); |
991 | if (s && s->state == BT_CONNECTED) { | 987 | if (s && s->state == BT_CONNECTED) { |
992 | err = -EEXIST; | 988 | up_write(&hidp_session_sem); |
993 | goto failed; | 989 | return -EEXIST; |
990 | } | ||
991 | |||
992 | session = kzalloc(sizeof(struct hidp_session), GFP_KERNEL); | ||
993 | if (!session) { | ||
994 | up_write(&hidp_session_sem); | ||
995 | return -ENOMEM; | ||
994 | } | 996 | } |
995 | 997 | ||
996 | session->conn = hidp_find_connection(session); | 998 | session->conn = hidp_find_connection(session); |