aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-06-22 08:48:11 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-07-09 16:42:17 -0400
commitcbbf472181bd5d6229decda96b34b0c2bbcb3050 (patch)
tree152e06ea436fcc419af1604a2f118f6be0ff33c9
parent4d22ea1532ba5730b665343e513d813c108c84ff (diff)
NFC: Release LLCP SAP when the owner is released
The LLCP SAP should only be freed when the socket owning it is released. As long as the socket is alive, the SAP should be reserved in order to e.g. send the right wks array when bringing the MAC up. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--net/nfc/llcp/llcp.c13
-rw-r--r--net/nfc/llcp/llcp.h3
-rw-r--r--net/nfc/llcp/sock.c9
3 files changed, 11 insertions, 14 deletions
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c
index 0c8d25e53ff6..1031abd13fc2 100644
--- a/net/nfc/llcp/llcp.c
+++ b/net/nfc/llcp/llcp.c
@@ -131,17 +131,6 @@ int nfc_llcp_local_put(struct nfc_llcp_local *local)
131 return kref_put(&local->ref, local_release); 131 return kref_put(&local->ref, local_release);
132} 132}
133 133
134static void nfc_llcp_clear_sdp(struct nfc_llcp_local *local)
135{
136 mutex_lock(&local->sdp_lock);
137
138 local->local_wks = 0;
139 local->local_sdp = 0;
140 local->local_sap = 0;
141
142 mutex_unlock(&local->sdp_lock);
143}
144
145static void nfc_llcp_timeout_work(struct work_struct *work) 134static void nfc_llcp_timeout_work(struct work_struct *work)
146{ 135{
147 struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local, 136 struct nfc_llcp_local *local = container_of(work, struct nfc_llcp_local,
@@ -993,8 +982,6 @@ void nfc_llcp_mac_is_down(struct nfc_dev *dev)
993 if (local == NULL) 982 if (local == NULL)
994 return; 983 return;
995 984
996 nfc_llcp_clear_sdp(local);
997
998 /* Close and purge all existing sockets */ 985 /* Close and purge all existing sockets */
999 nfc_llcp_socket_release(local, true); 986 nfc_llcp_socket_release(local, true);
1000} 987}
diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h
index 7286c86982ff..374cc4779af4 100644
--- a/net/nfc/llcp/llcp.h
+++ b/net/nfc/llcp/llcp.h
@@ -113,6 +113,9 @@ struct nfc_llcp_sock {
113 /* Is the remote peer ready to receive */ 113 /* Is the remote peer ready to receive */
114 u8 remote_ready; 114 u8 remote_ready;
115 115
116 /* Reserved source SAP */
117 u8 reserved_ssap;
118
116 struct sk_buff_head tx_queue; 119 struct sk_buff_head tx_queue;
117 struct sk_buff_head tx_pending_queue; 120 struct sk_buff_head tx_pending_queue;
118 struct sk_buff_head tx_backlog_queue; 121 struct sk_buff_head tx_backlog_queue;
diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c
index b08e99d2c715..211cb234f7a3 100644
--- a/net/nfc/llcp/sock.c
+++ b/net/nfc/llcp/sock.c
@@ -124,6 +124,8 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
124 if (llcp_sock->ssap == LLCP_MAX_SAP) 124 if (llcp_sock->ssap == LLCP_MAX_SAP)
125 goto put_dev; 125 goto put_dev;
126 126
127 llcp_sock->reserved_ssap = llcp_sock->ssap;
128
127 nfc_llcp_sock_link(&local->sockets, sk); 129 nfc_llcp_sock_link(&local->sockets, sk);
128 130
129 pr_debug("Socket bound to SAP %d\n", llcp_sock->ssap); 131 pr_debug("Socket bound to SAP %d\n", llcp_sock->ssap);
@@ -409,7 +411,8 @@ static int llcp_sock_release(struct socket *sock)
409 } 411 }
410 } 412 }
411 413
412 nfc_llcp_put_ssap(llcp_sock->local, llcp_sock->ssap); 414 if (llcp_sock->reserved_ssap < LLCP_SAP_MAX)
415 nfc_llcp_put_ssap(llcp_sock->local, llcp_sock->ssap);
413 416
414 release_sock(sk); 417 release_sock(sk);
415 418
@@ -489,6 +492,9 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
489 ret = -ENOMEM; 492 ret = -ENOMEM;
490 goto put_dev; 493 goto put_dev;
491 } 494 }
495
496 llcp_sock->reserved_ssap = llcp_sock->ssap;
497
492 if (addr->service_name_len == 0) 498 if (addr->service_name_len == 0)
493 llcp_sock->dsap = addr->dsap; 499 llcp_sock->dsap = addr->dsap;
494 else 500 else
@@ -690,6 +696,7 @@ struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp)
690 llcp_sock->send_n = llcp_sock->send_ack_n = 0; 696 llcp_sock->send_n = llcp_sock->send_ack_n = 0;
691 llcp_sock->recv_n = llcp_sock->recv_ack_n = 0; 697 llcp_sock->recv_n = llcp_sock->recv_ack_n = 0;
692 llcp_sock->remote_ready = 1; 698 llcp_sock->remote_ready = 1;
699 llcp_sock->reserved_ssap = LLCP_SAP_MAX;
693 skb_queue_head_init(&llcp_sock->tx_queue); 700 skb_queue_head_init(&llcp_sock->tx_queue);
694 skb_queue_head_init(&llcp_sock->tx_pending_queue); 701 skb_queue_head_init(&llcp_sock->tx_pending_queue);
695 skb_queue_head_init(&llcp_sock->tx_backlog_queue); 702 skb_queue_head_init(&llcp_sock->tx_backlog_queue);