Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86/hyperv: Fix error pointer dereference

The function idle_thread_get() can return an error pointer and is not
checked for it. Add check for error pointer.

Detected by Smatch:
arch/x86/hyperv/hv_vtl.c:126 hv_vtl_bringup_vcpu() error:
'idle' dereferencing possible ERR_PTR()

Fixes: 2b4b90e053a29 ("x86/hyperv: Use per cpu initial stack for vtl context")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>

authored by

Ethan Tidmore and committed by
Wei Liu
705d01c8 fe9f1598

+5 -3
+5 -3
arch/x86/hyperv/hv_vtl.c
··· 110 110 111 111 static int hv_vtl_bringup_vcpu(u32 target_vp_index, int cpu, u64 eip_ignored) 112 112 { 113 - u64 status; 113 + u64 status, rsp, rip; 114 114 int ret = 0; 115 115 struct hv_enable_vp_vtl *input; 116 116 unsigned long irq_flags; ··· 123 123 struct desc_struct *gdt; 124 124 125 125 struct task_struct *idle = idle_thread_get(cpu); 126 - u64 rsp = (unsigned long)idle->thread.sp; 126 + if (IS_ERR(idle)) 127 + return PTR_ERR(idle); 127 128 128 - u64 rip = (u64)&hv_vtl_ap_entry; 129 + rsp = (unsigned long)idle->thread.sp; 130 + rip = (u64)&hv_vtl_ap_entry; 129 131 130 132 native_store_gdt(&gdt_ptr); 131 133 store_idt(&idt_ptr);