diff options
Diffstat (limited to 'src/peer.c')
-rw-r--r-- | src/peer.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -22,20 +22,23 @@ struct wg_peer *wg_peer_create(struct wg_device *wg, const u8 preshared_key[NOISE_SYMMETRIC_KEY_LEN]) { struct wg_peer *peer; + int ret = -ENOMEM; lockdep_assert_held(&wg->device_update_lock); if (wg->num_peers >= MAX_PEERS_PER_DEVICE) - return NULL; + return ERR_PTR(ret); peer = kzalloc(sizeof(*peer), GFP_KERNEL); if (unlikely(!peer)) - return NULL; + return ERR_PTR(ret); peer->device = wg; if (!wg_noise_handshake_init(&peer->handshake, &wg->static_identity, - public_key, preshared_key, peer)) + public_key, preshared_key, peer)) { + ret = -EKEYREJECTED; goto err_1; + } if (dst_cache_init(&peer->endpoint_cache, GFP_KERNEL)) goto err_1; if (wg_packet_queue_init(&peer->tx_queue, wg_packet_tx_worker, false, @@ -74,7 +77,7 @@ err_2: dst_cache_destroy(&peer->endpoint_cache); err_1: kfree(peer); - return NULL; + return ERR_PTR(ret); } struct wg_peer *wg_peer_get_maybe_zero(struct wg_peer *peer) |