Commit 8938c105 authored by Ben Hutchings's avatar Ben Hutchings Committed by Greg Kroah-Hartman

genirq: Fix race in register_irq_proc()

commit 95c2b17534654829db428f11bcf4297c059a2a7e upstream.

Per-IRQ directories in procfs are created only when a handler is first
added to the irqdesc, not when the irqdesc is created.  In the case of
a shared IRQ, multiple tasks can race to create a directory.  This
race condition seems to have been present forever, but is easier to
hit with async probing.
Signed-off-by: default avatarBen Hutchings <>
Link: default avatarThomas Gleixner <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent e9346b9a
......@@ -12,6 +12,7 @@
#include <linux/seq_file.h>
#include <linux/interrupt.h>
#include <linux/kernel_stat.h>
#include <linux/mutex.h>
#include "internals.h"
......@@ -309,18 +310,29 @@ void register_handler_proc(unsigned int irq, struct irqaction *action)
void register_irq_proc(unsigned int irq, struct irq_desc *desc)
static DEFINE_MUTEX(register_lock);
char name [MAX_NAMELEN];
if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip) || desc->dir)
if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip))
* irq directories are registered only when a handler is
* added, not when the descriptor is created, so multiple
* tasks might try to register at the same time.
if (desc->dir)
goto out_unlock;
memset(name, 0, MAX_NAMELEN);
sprintf(name, "%d", irq);
/* create /proc/irq/1234 */
desc->dir = proc_mkdir(name, root_irq_dir);
if (!desc->dir)
goto out_unlock;
/* create /proc/irq/<irq>/smp_affinity */
......@@ -341,6 +353,9 @@ void register_irq_proc(unsigned int irq, struct irq_desc *desc)
proc_create_data("spurious", 0444, desc->dir,
&irq_spurious_proc_fops, (void *)(long)irq);
void unregister_irq_proc(unsigned int irq, struct irq_desc *desc)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment