Skip to content

Commit 884cd28

Browse files
Ethan Tidmoregregkh
authored andcommitted
x86/hyperv: Fix error pointer dereference
[ Upstream commit 705d01c ] 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: 2b4b90e ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent bc70c38 commit 884cd28

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

arch/x86/hyperv/hv_vtl.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static void hv_vtl_ap_entry(void)
110110

111111
static int hv_vtl_bringup_vcpu(u32 target_vp_index, int cpu, u64 eip_ignored)
112112
{
113-
u64 status;
113+
u64 status, rsp, rip;
114114
int ret = 0;
115115
struct hv_enable_vp_vtl *input;
116116
unsigned long irq_flags;
@@ -123,9 +123,11 @@ static int hv_vtl_bringup_vcpu(u32 target_vp_index, int cpu, u64 eip_ignored)
123123
struct desc_struct *gdt;
124124

125125
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);
127128

128-
u64 rip = (u64)&hv_vtl_ap_entry;
129+
rsp = (unsigned long)idle->thread.sp;
130+
rip = (u64)&hv_vtl_ap_entry;
129131

130132
native_store_gdt(&gdt_ptr);
131133
store_idt(&idt_ptr);

0 commit comments

Comments
 (0)