/* Note: 'tipc_net_lock' is write_locked, bearer is locked. This routine must not grab the node lock until after link timer cancellation to avoid a potential deadlock situation.  */
void tipc_link_delete(struct link *l_ptr)
/* Note: 'tipc_net_lock' is write_locked, bearer is locked. This routine must not grab the node lock until after link timer cancellation to avoid a potential deadlock situation.  */
void tipc_link_delete(struct link *l_ptr)
{
	if (!l_ptr) {
		err("Attempt to delete non-existent link\n");
		return;
	}
	dbg("tipc_link_delete()\n");
	k_cancel_timer(&l_ptr->timer);
	tipc_node_lock(l_ptr->owner);
	tipc_link_reset(l_ptr);
	tipc_node_detach_link(l_ptr->owner, l_ptr);
	tipc_link_stop(l_ptr);
	list_del_init(&l_ptr->link_list);
	if (LINK_LOG_BUF_SIZE)
		kfree(l_ptr->print_buf.buf);
	tipc_node_unlock(l_ptr->owner);
	k_term_timer(&l_ptr->timer);
	kfree(l_ptr);
}