NFC: Close listening LLCP sockets when the device is gone
When the MAC link goes down, we should only keep the bound sockets alive. They will be closed by sock_release or when the underlying NFC device is moving away. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
b8e7a06d9c
commit
4d22ea1532
|
@ -45,7 +45,7 @@ void nfc_llcp_sock_unlink(struct llcp_sock_list *l, struct sock *sk)
|
||||||
write_unlock(&l->lock);
|
write_unlock(&l->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nfc_llcp_socket_release(struct nfc_llcp_local *local)
|
static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool listen)
|
||||||
{
|
{
|
||||||
struct sock *sk;
|
struct sock *sk;
|
||||||
struct hlist_node *node, *tmp;
|
struct hlist_node *node, *tmp;
|
||||||
|
@ -78,6 +78,11 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local)
|
||||||
|
|
||||||
sock_orphan(accept_sk);
|
sock_orphan(accept_sk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (listen == true) {
|
||||||
|
release_sock(sk);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sk->sk_state = LLCP_CLOSED;
|
sk->sk_state = LLCP_CLOSED;
|
||||||
|
@ -106,7 +111,7 @@ static void local_release(struct kref *ref)
|
||||||
local = container_of(ref, struct nfc_llcp_local, ref);
|
local = container_of(ref, struct nfc_llcp_local, ref);
|
||||||
|
|
||||||
list_del(&local->list);
|
list_del(&local->list);
|
||||||
nfc_llcp_socket_release(local);
|
nfc_llcp_socket_release(local, false);
|
||||||
del_timer_sync(&local->link_timer);
|
del_timer_sync(&local->link_timer);
|
||||||
skb_queue_purge(&local->tx_queue);
|
skb_queue_purge(&local->tx_queue);
|
||||||
destroy_workqueue(local->tx_wq);
|
destroy_workqueue(local->tx_wq);
|
||||||
|
@ -991,7 +996,7 @@ void nfc_llcp_mac_is_down(struct nfc_dev *dev)
|
||||||
nfc_llcp_clear_sdp(local);
|
nfc_llcp_clear_sdp(local);
|
||||||
|
|
||||||
/* Close and purge all existing sockets */
|
/* Close and purge all existing sockets */
|
||||||
nfc_llcp_socket_release(local);
|
nfc_llcp_socket_release(local, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx,
|
void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx,
|
||||||
|
|
Loading…
Reference in New Issue