flush_workqueue(rxrpc_workqueue);
rxrpc_purge_queue(&sk->sk_receive_queue);
- if (rx->local) {
- rxrpc_put_local(rx->local);
- rx->local = NULL;
- }
-
+ rxrpc_put_local(rx->local);
+ rx->local = NULL;
key_put(rx->key);
rx->key = NULL;
key_put(rx->securities);
return conn->proto.in_clientflag;
}
+static inline void rxrpc_get_connection(struct rxrpc_connection *conn)
+{
+ atomic_inc(&conn->usage);
+}
+
+static inline
+struct rxrpc_connection *rxrpc_get_connection_maybe(struct rxrpc_connection *conn)
+{
+ return atomic_inc_not_zero(&conn->usage) ? conn : NULL;
+}
+
/*
* input.c
*/
static inline void rxrpc_put_local(struct rxrpc_local *local)
{
- if (atomic_dec_and_test(&local->usage))
+ if (local && atomic_dec_and_test(&local->usage))
__rxrpc_put_local(local);
}
extern void __rxrpc_put_peer(struct rxrpc_peer *peer);
static inline void rxrpc_put_peer(struct rxrpc_peer *peer)
{
- if (atomic_dec_and_test(&peer->usage))
+ if (peer && atomic_dec_and_test(&peer->usage))
__rxrpc_put_peer(peer);
}
_debug("await conn sec");
list_add_tail(&call->accept_link, &rx->secureq);
call->conn->state = RXRPC_CONN_SERVER_CHALLENGING;
- atomic_inc(&call->conn->usage);
+ rxrpc_get_connection(call->conn);
set_bit(RXRPC_CONN_CHALLENGE, &call->conn->events);
rxrpc_queue_conn(call->conn);
} else {
rb_insert_color(&call->conn_node, &conn->calls);
conn->channels[call->channel] = call;
sock_hold(&rx->sk);
- atomic_inc(&conn->usage);
+ rxrpc_get_connection(conn);
write_unlock_bh(&conn->lock);
spin_lock(&conn->params.peer->lock);
_enter("{%d}", conn->debug_id);
- atomic_inc(&conn->usage);
+ rxrpc_get_connection(conn);
if (test_and_clear_bit(RXRPC_CONN_CHALLENGE, &conn->events)) {
rxrpc_secure_connection(conn);
* channel.
*/
chan = 0;
- atomic_inc(&conn->usage);
+ rxrpc_get_connection(conn);
conn->avail_calls = RXRPC_MAXCALLS - 1;
conn->channels[chan] = call;
conn->call_counter = 1;
conn->channels[1] == NULL ||
conn->channels[2] == NULL ||
conn->channels[3] == NULL);
- atomic_inc(&conn->usage);
+ rxrpc_get_connection(conn);
break;
}
conn->channels[1] == NULL &&
conn->channels[2] == NULL &&
conn->channels[3] == NULL);
- atomic_inc(&conn->usage);
+ rxrpc_get_connection(conn);
list_move(&conn->bundle_link, &bundle->avail_conns);
break;
}
read_unlock_bh(&trans->conn_lock);
goto security_mismatch;
}
- atomic_inc(&conn->usage);
+ rxrpc_get_connection(conn);
read_unlock_bh(&trans->conn_lock);
goto success;
write_unlock_bh(&trans->conn_lock);
goto security_mismatch;
}
- atomic_inc(&conn->usage);
+ rxrpc_get_connection(conn);
write_unlock_bh(&trans->conn_lock);
kfree(candidate);
goto success;
return NULL;
found:
- atomic_inc(&conn->usage);
+ rxrpc_get_connection(conn);
read_unlock_bh(&trans->conn_lock);
_leave(" = %p", conn);
return conn;
{
_enter("%p,%p", conn, skb);
- atomic_inc(&conn->usage);
+ rxrpc_get_connection(conn);
skb_queue_tail(&conn->rx_queue, skb);
rxrpc_queue_conn(conn);
}
* bind the transport socket may still fail if we're attempting
* to use a local address that the dying object is still using.
*/
- if (!atomic_inc_not_zero(&local->usage)) {
+ if (!rxrpc_get_local_maybe(local)) {
cursor = cursor->next;
list_del_init(&local->link);
break;