Skip to content

Commit 01af08b

Browse files
committed
Merge tag 'irq-urgent-2020-03-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull irq fix from Thomas Gleixner: "A single bugfix to prevent reference leaks in irq affinity notifiers" * tag 'irq-urgent-2020-03-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: genirq: Fix reference leaks on irq affinity notifiers
2 parents e595dd9 + df81dfc commit 01af08b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

kernel/irq/manage.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,11 @@ int irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask,
323323

324324
if (desc->affinity_notify) {
325325
kref_get(&desc->affinity_notify->kref);
326-
schedule_work(&desc->affinity_notify->work);
326+
if (!schedule_work(&desc->affinity_notify->work)) {
327+
/* Work was already scheduled, drop our extra ref */
328+
kref_put(&desc->affinity_notify->kref,
329+
desc->affinity_notify->release);
330+
}
327331
}
328332
irqd_set(data, IRQD_AFFINITY_SET);
329333

@@ -423,7 +427,10 @@ irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify)
423427
raw_spin_unlock_irqrestore(&desc->lock, flags);
424428

425429
if (old_notify) {
426-
cancel_work_sync(&old_notify->work);
430+
if (cancel_work_sync(&old_notify->work)) {
431+
/* Pending work had a ref, put that one too */
432+
kref_put(&old_notify->kref, old_notify->release);
433+
}
427434
kref_put(&old_notify->kref, old_notify->release);
428435
}
429436

0 commit comments

Comments
 (0)