]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.93/genirq-affinity-don-t-return-with-empty-affinity-masks-on-error.patch
Linux 4.14.93
[thirdparty/kernel/stable-queue.git] / releases / 4.14.93 / genirq-affinity-don-t-return-with-empty-affinity-masks-on-error.patch
CommitLineData
8f7d25df
GKH
1From 0211e12dd0a5385ecffd3557bc570dbad7fcf245 Mon Sep 17 00:00:00 2001
2From: Thomas Gleixner <tglx@linutronix.de>
3Date: Wed, 4 Apr 2018 12:40:07 +0200
4Subject: genirq/affinity: Don't return with empty affinity masks on error
5
6From: Thomas Gleixner <tglx@linutronix.de>
7
8commit 0211e12dd0a5385ecffd3557bc570dbad7fcf245 upstream.
9
10When the allocation of node_to_possible_cpumask fails, then
11irq_create_affinity_masks() returns with a pointer to the empty affinity
12masks array, which will cause malfunction.
13
14Reorder the allocations so the masks array allocation comes last and every
15failure path returns NULL.
16
17Fixes: 9a0ef98e186d ("genirq/affinity: Assign vectors to all present CPUs")
18Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
19Cc: Christoph Hellwig <hch@infradead.org>
20Cc: Ming Lei <ming.lei@redhat.com>
21Cc: Mihai Carabas <mihai.carabas@oracle.com>
22Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23
24---
25 kernel/irq/affinity.c | 15 ++++++++-------
26 1 file changed, 8 insertions(+), 7 deletions(-)
27
28--- a/kernel/irq/affinity.c
29+++ b/kernel/irq/affinity.c
30@@ -108,7 +108,7 @@ irq_create_affinity_masks(int nvecs, con
31 int affv = nvecs - affd->pre_vectors - affd->post_vectors;
32 int last_affv = affv + affd->pre_vectors;
33 nodemask_t nodemsk = NODE_MASK_NONE;
34- struct cpumask *masks;
35+ struct cpumask *masks = NULL;
36 cpumask_var_t nmsk, *node_to_possible_cpumask;
37
38 /*
39@@ -121,13 +121,13 @@ irq_create_affinity_masks(int nvecs, con
40 if (!zalloc_cpumask_var(&nmsk, GFP_KERNEL))
41 return NULL;
42
43- masks = kcalloc(nvecs, sizeof(*masks), GFP_KERNEL);
44- if (!masks)
45- goto out;
46-
47 node_to_possible_cpumask = alloc_node_to_possible_cpumask();
48 if (!node_to_possible_cpumask)
49- goto out;
50+ goto outcpumsk;
51+
52+ masks = kcalloc(nvecs, sizeof(*masks), GFP_KERNEL);
53+ if (!masks)
54+ goto outnodemsk;
55
56 /* Fill out vectors at the beginning that don't need affinity */
57 for (curvec = 0; curvec < affd->pre_vectors; curvec++)
58@@ -192,8 +192,9 @@ done:
59 /* Fill out vectors at the end that don't need affinity */
60 for (; curvec < nvecs; curvec++)
61 cpumask_copy(masks + curvec, irq_default_affinity);
62+outnodemsk:
63 free_node_to_possible_cpumask(node_to_possible_cpumask);
64-out:
65+outcpumsk:
66 free_cpumask_var(nmsk);
67 return masks;
68 }