blob: a72c509894d27e6c43676b65eef323da532722b3 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: "Jason A. Donenfeld" <Jason@zx2c4.com>
3Date: Wed, 29 Apr 2020 14:59:21 -0600
4Subject: [PATCH] wireguard: queueing: cleanup ptr_ring in error path of
5 packet_queue_init
6
7commit 130c58606171326c81841a49cc913cd354113dd9 upstream.
8
9Prior, if the alloc_percpu of packet_percpu_multicore_worker_alloc
10failed, the previously allocated ptr_ring wouldn't be freed. This commit
11adds the missing call to ptr_ring_cleanup in the error case.
12
13Reported-by: Sultan Alsawaf <sultan@kerneltoast.com>
14Fixes: e7096c131e51 ("net: WireGuard secure network tunnel")
15Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
16Signed-off-by: David S. Miller <davem@davemloft.net>
17Signed-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 }