98ff785f390e28ba246da9177376742c9abbdb07
[openwrt/staging/dangole.git] /
1 From 08d5c8fc96361389fdd982477aaf6d7c9311f5e0 Mon Sep 17 00:00:00 2001
2 From: "Jason A. Donenfeld" <Jason@zx2c4.com>
3 Date: Wed, 29 Apr 2020 14:59:21 -0600
4 Subject: [PATCH 096/124] wireguard: queueing: cleanup ptr_ring in error path
5 of packet_queue_init
6
7 commit 130c58606171326c81841a49cc913cd354113dd9 upstream.
8
9 Prior, if the alloc_percpu of packet_percpu_multicore_worker_alloc
10 failed, the previously allocated ptr_ring wouldn't be freed. This commit
11 adds the missing call to ptr_ring_cleanup in the error case.
12
13 Reported-by: Sultan Alsawaf <sultan@kerneltoast.com>
14 Fixes: e7096c131e51 ("net: WireGuard secure network tunnel")
15 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
18 ---
19 drivers/net/wireguard/queueing.c | 4 +++-
20 1 file changed, 3 insertions(+), 1 deletion(-)
21
22 --- a/drivers/net/wireguard/queueing.c
23 +++ b/drivers/net/wireguard/queueing.c
24 @@ -35,8 +35,10 @@ int wg_packet_queue_init(struct crypt_qu
25 if (multicore) {
26 queue->worker = wg_packet_percpu_multicore_worker_alloc(
27 function, queue);
28 - if (!queue->worker)
29 + if (!queue->worker) {
30 + ptr_ring_cleanup(&queue->ring, NULL);
31 return -ENOMEM;
32 + }
33 } else {
34 INIT_WORK(&queue->work, function);
35 }