blob: 09ccc8e0b54f3a96c823f96fc0c771d89b85aba0 [file] [log] [blame]
From db3ee748eeee2324029d80f9bd85fe5798f52637 Mon Sep 17 00:00:00 2001
From: Oliver O'Halloran <>
Date: Thu, 6 Feb 2020 17:26:21 +1100
Subject: [PATCH] cpufreq: powernv: Fix use-after-free
commit d0a72efac89d1c35ac55197895201b7b94c5e6ef upstream.
The cpufreq driver has a use-after-free that we can hit if:
a) There's an OCC message pending when the notifier is registered, and
b) The cpufreq driver fails to register with the core.
When a) occurs the notifier schedules a workqueue item to handle the
message. The backing work_struct is located on chips[].throttle and
when b) happens we clean up by freeing the array. Once we get to
the (now free) queued item and the kernel crashes.
Fixes: c5e29ea7ac14 ("cpufreq: powernv: Fix bugs in powernv_cpufreq_{init/exit}")
Cc: # v4.6+
Signed-off-by: Oliver O'Halloran <>
Reviewed-by: Gautham R. Shenoy <>
Signed-off-by: Michael Ellerman <>
Signed-off-by: Paul Gortmaker <>
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 56f4bc0d209e..1806b1da4366 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -1080,6 +1080,12 @@ static int init_chip_info(void)
static inline void clean_chip_info(void)
+ int i;
+ /* flush any pending work items */
+ if (chips)
+ for (i = 0; i < nr_chips; i++)
+ cancel_work_sync(&chips[i].throttle);