Skip to content

Commit feabeca

Browse files
Sergey ShtylyovKAGA-KOKO
authored andcommitted
genirq/ipi: Fix NULL pointer deref in irq_data_get_affinity_mask()
If ipi_send_{mask|single}() is called with an invalid interrupt number, all the local variables there will be NULL. ipi_send_verify() which is invoked from these functions does verify its 'data' parameter, resulting in a kernel oops in irq_data_get_affinity_mask() as the passed NULL pointer gets dereferenced. Add a missing NULL pointer check in ipi_send_verify()... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Fixes: 3b8e29a ("genirq: Implement ipi_send_mask/single()") Signed-off-by: Sergey Shtylyov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c9c3395 commit feabeca

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

kernel/irq/ipi.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ EXPORT_SYMBOL_GPL(ipi_get_hwirq);
188188
static int ipi_send_verify(struct irq_chip *chip, struct irq_data *data,
189189
const struct cpumask *dest, unsigned int cpu)
190190
{
191-
const struct cpumask *ipimask = irq_data_get_affinity_mask(data);
191+
const struct cpumask *ipimask;
192192

193-
if (!chip || !ipimask)
193+
if (!chip || !data)
194194
return -EINVAL;
195195

196196
if (!chip->ipi_send_single && !chip->ipi_send_mask)
@@ -199,6 +199,10 @@ static int ipi_send_verify(struct irq_chip *chip, struct irq_data *data,
199199
if (cpu >= nr_cpu_ids)
200200
return -EINVAL;
201201

202+
ipimask = irq_data_get_affinity_mask(data);
203+
if (!ipimask)
204+
return -EINVAL;
205+
202206
if (dest) {
203207
if (!cpumask_subset(dest, ipimask))
204208
return -EINVAL;

0 commit comments

Comments
 (0)