diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-04 12:39:27 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-04 12:54:26 +0100 |
commit | 835a11c7c1abc5ad19b0972b45d28169f8965958 (patch) | |
tree | 109bf683b0bb38c444412487553a19f2579dc305 /src | |
parent | 339b9c47d9aed8244c0cb1365a78b1918e5e69a1 (diff) |
data: take reference to peer
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/data.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -156,6 +156,7 @@ static void finish_encryption(struct padata_priv *padata) struct packet_data_encryption_ctx *ctx = container_of(padata, struct packet_data_encryption_ctx, padata); ctx->callback(ctx->skb, ctx->peer); + peer_put(ctx->peer); } static inline int start_encryption(struct padata_instance *padata, struct padata_priv *priv, int cb_cpu) @@ -235,9 +236,15 @@ int packet_create_data(struct sk_buff *skb, struct wireguard_peer *peer, void(*c #ifdef CONFIG_WIREGUARD_PARALLEL if ((parallel || padata_queue_len(peer->device->parallel_send) > 0) && cpumask_weight(cpu_online_mask) > 1) { unsigned int cpu = choose_cpu(keypair->remote_index); + ret = -EBUSY; + ctx->peer = peer_rcu_get(peer); + if (unlikely(!ctx->peer)) + goto err; ret = start_encryption(peer->device->parallel_send, &ctx->padata, cpu); - if (unlikely(ret < 0)) + if (unlikely(ret < 0)) { + peer_put(ctx->peer); goto err; + } } else #endif { |