aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc/llcp/sock.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-05-04 05:24:16 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-06-04 15:34:28 -0400
commitc7aa12252f5142b9eee2f6e34ca8870a8e7e048c (patch)
treee91c72609e7d13b3a185cf75acd74a8385c736c5 /net/nfc/llcp/sock.c
parentf8f5701bdaf9134b1f90e5044a82c66324d2073f (diff)
NFC: Take a reference on the LLCP local pointer when creating a socket
LLCP sockets point to their local LLCP service, so they need to take a reference on it. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc/llcp/sock.c')
-rw-r--r--net/nfc/llcp/sock.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c
index 3f339b19d140..9ac397b17718 100644
--- a/net/nfc/llcp/sock.c
+++ b/net/nfc/llcp/sock.c
@@ -111,7 +111,7 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
111 } 111 }
112 112
113 llcp_sock->dev = dev; 113 llcp_sock->dev = dev;
114 llcp_sock->local = local; 114 llcp_sock->local = nfc_llcp_local_get(local);
115 llcp_sock->nfc_protocol = llcp_addr.nfc_protocol; 115 llcp_sock->nfc_protocol = llcp_addr.nfc_protocol;
116 llcp_sock->service_name_len = min_t(unsigned int, 116 llcp_sock->service_name_len = min_t(unsigned int,
117 llcp_addr.service_name_len, 117 llcp_addr.service_name_len,
@@ -487,7 +487,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
487 } 487 }
488 488
489 llcp_sock->dev = dev; 489 llcp_sock->dev = dev;
490 llcp_sock->local = local; 490 llcp_sock->local = nfc_llcp_local_get(local);
491 llcp_sock->ssap = nfc_llcp_get_local_ssap(local); 491 llcp_sock->ssap = nfc_llcp_get_local_ssap(local);
492 if (llcp_sock->ssap == LLCP_SAP_MAX) { 492 if (llcp_sock->ssap == LLCP_SAP_MAX) {
493 ret = -ENOMEM; 493 ret = -ENOMEM;
@@ -701,8 +701,6 @@ struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp)
701 701
702void nfc_llcp_sock_free(struct nfc_llcp_sock *sock) 702void nfc_llcp_sock_free(struct nfc_llcp_sock *sock)
703{ 703{
704 struct nfc_llcp_local *local = sock->local;
705
706 kfree(sock->service_name); 704 kfree(sock->service_name);
707 705
708 skb_queue_purge(&sock->tx_queue); 706 skb_queue_purge(&sock->tx_queue);
@@ -710,13 +708,11 @@ void nfc_llcp_sock_free(struct nfc_llcp_sock *sock)
710 skb_queue_purge(&sock->tx_backlog_queue); 708 skb_queue_purge(&sock->tx_backlog_queue);
711 709
712 list_del_init(&sock->accept_queue); 710 list_del_init(&sock->accept_queue);
713 711 list_del_init(&sock->list);
714 if (local != NULL && sock == local->sockets[sock->ssap])
715 local->sockets[sock->ssap] = NULL;
716 else
717 list_del_init(&sock->list);
718 712
719 sock->parent = NULL; 713 sock->parent = NULL;
714
715 nfc_llcp_local_put(sock->local);
720} 716}
721 717
722static int llcp_sock_create(struct net *net, struct socket *sock, 718static int llcp_sock_create(struct net *net, struct socket *sock,