From 7726e4b8c6e09a2a5269751e17b2af920b919435 Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Tue, 28 May 2019 10:42:15 +0200
Subject: [PATCH 453/518] genirq: Handle missing work_struct in
 irq_set_affinity_notifier()

[ Upstream commit bbc4d2a7d6ff54ba923640d9a42c7bef7185fe98 ]

The backported stable commit
   59c39840f5abf ("genirq: Prevent use-after-free and work list corruption")

added cancel_work_sync() on a work_struct element which is not available
in RT.

Replace cancel_work_sync() with kthread_cancel_work_sync() on RT.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Tom Zanussi <zanussi@kernel.org>

 Conflicts:
	kernel/irq/manage.c
---
 kernel/irq/manage.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index c70f06160142f..cff75499c5191 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -392,12 +392,14 @@ irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify)
 	raw_spin_unlock_irqrestore(&desc->lock, flags);
 
 	if (old_notify) {
-#ifndef CONFIG_PREEMPT_RT_BASE
+#ifdef CONFIG_PREEMPT_RT_BASE
+		if (kthread_cancel_work_sync(&notify->work)) {
+#else
 		if (cancel_work_sync(&old_notify->work)) {
+#endif
 			/* Pending work had a ref, put that one too */
 			kref_put(&old_notify->kref, old_notify->release);
 		}
-#endif
 		kref_put(&old_notify->kref, old_notify->release);
 	}
 
-- 
2.41.0

