* Re: [PATCH] cpu/hotplug: check the return value of idle_thread_get
2023-03-27 20:37 [PATCH] cpu/hotplug: check the return value of idle_thread_get Chao Liu
@ 2022-05-18 8:55 ` Thomas Gleixner
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2022-05-18 8:55 UTC (permalink / raw)
To: Chao Liu, linux-kernel, hewenliang4; +Cc: steven.price, Peter Zijlstra
On Mon, Mar 27 2023 at 20:37, Chao Liu wrote:
> ilde may be ERR_PTR()
Yes, but if that happens in bringup_cpu() or finish_cpu() it would be a
serious bug and the error pointer dereference would be the least of the
problems.
If the initial check in _cpu_up() failed for a CPU then the above
functions cannot be invoked for that CPU ever.
Thanks,
tglx
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] cpu/hotplug: check the return value of idle_thread_get
@ 2023-03-27 20:37 Chao Liu
2022-05-18 8:55 ` Thomas Gleixner
0 siblings, 1 reply; 2+ messages in thread
From: Chao Liu @ 2023-03-27 20:37 UTC (permalink / raw)
To: linux-kernel, hewenliang4; +Cc: tglx, steven.price
ilde may be ERR_PTR()
Signed-off-by: Chao Liu <liuchao173@huawei.com>
---
kernel/cpu.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index d0a9aa0b42e8..8ddf372e8d29 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -590,6 +590,9 @@ static int bringup_cpu(unsigned int cpu)
struct task_struct *idle = idle_thread_get(cpu);
int ret;
+ if (IS_ERR(idle))
+ return PTR_ERR(idle);
+
/*
* Reset stale stack state from the last time this CPU was online.
*/
@@ -614,7 +617,12 @@ static int bringup_cpu(unsigned int cpu)
static int finish_cpu(unsigned int cpu)
{
struct task_struct *idle = idle_thread_get(cpu);
- struct mm_struct *mm = idle->active_mm;
+ struct mm_struct *mm = NULL;
+
+ if (IS_ERR(idle))
+ return PTR_ERR(idle);
+
+ mm = idle->active_mm;
/*
* idle_task_exit() will have switched to &init_mm, now
--
2.23.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-18 8:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-27 20:37 [PATCH] cpu/hotplug: check the return value of idle_thread_get Chao Liu
2022-05-18 8:55 ` Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox