mutex_unlock(&call->user_mutex);
        }
 
+       rxrpc_put_peer(cp.peer);
        _leave(" = %p", call);
        return call;
 }
                ret = rxrpc_retry_client_call(rx, call, &cp, srx, GFP_KERNEL);
 
        mutex_unlock(&call->user_mutex);
+       rxrpc_put_peer(cp.peer);
        _leave(" = %d", ret);
        return ret;
 }
 
 struct rxrpc_peer *rxrpc_alloc_peer(struct rxrpc_local *, gfp_t);
 struct rxrpc_peer *rxrpc_lookup_incoming_peer(struct rxrpc_local *,
                                              struct rxrpc_peer *);
+void rxrpc_destroy_all_peers(struct rxrpc_net *);
 struct rxrpc_peer *rxrpc_get_peer(struct rxrpc_peer *);
 struct rxrpc_peer *rxrpc_get_peer_maybe(struct rxrpc_peer *);
 void rxrpc_put_peer(struct rxrpc_peer *);
 
        cancel_work_sync(&rxnet->peer_keepalive_work);
        rxrpc_destroy_all_calls(rxnet);
        rxrpc_destroy_all_connections(rxnet);
+       rxrpc_destroy_all_peers(rxnet);
        rxrpc_destroy_all_locals(rxnet);
        proc_remove(rxnet->proc_net);
 }
 
        }
 }
 
+/*
+ * Make sure all peer records have been discarded.
+ */
+void rxrpc_destroy_all_peers(struct rxrpc_net *rxnet)
+{
+       struct rxrpc_peer *peer;
+       int i;
+
+       for (i = 0; i < HASH_SIZE(rxnet->peer_hash); i++) {
+               if (hlist_empty(&rxnet->peer_hash[i]))
+                       continue;
+
+               hlist_for_each_entry(peer, &rxnet->peer_hash[i], hash_link) {
+                       pr_err("Leaked peer %u {%u} %pISp\n",
+                              peer->debug_id,
+                              atomic_read(&peer->usage),
+                              &peer->srx.transport);
+               }
+       }
+}
+
 /**
  * rxrpc_kernel_get_peer - Get the peer address of a call
  * @sock: The socket on which the call is in progress.
 
                                     atomic_inc_return(&rxrpc_debug_id));
        /* The socket is now unlocked */
 
+       rxrpc_put_peer(cp.peer);
        _leave(" = %p\n", call);
        return call;
 }