From e6f93609728d0ad864fc2d7dacd9df128eccd37a Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 4 Feb 2014 19:07:47 +0100 Subject: Fix potential NULL dereference Found by Coverity * i386/i386/user_ldt.c (i386_get_ldt): Fetch `pcb' field of `thread' only after looking for `thread' being NULL. --- i386/i386/user_ldt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i386/i386/user_ldt.c b/i386/i386/user_ldt.c index a83bc12..3a2c1cc 100644 --- a/i386/i386/user_ldt.c +++ b/i386/i386/user_ldt.c @@ -262,7 +262,7 @@ i386_get_ldt(thread, first_selector, selector_count, desc_list, count) unsigned int *count; /* in/out */ { struct user_ldt *user_ldt; - pcb_t pcb = thread->pcb; + pcb_t pcb; int first_desc = sel_idx(first_selector); unsigned int ldt_count; vm_size_t ldt_size; @@ -276,6 +276,7 @@ i386_get_ldt(thread, first_selector, selector_count, desc_list, count) if (first_desc + selector_count >= 8192) return KERN_INVALID_ARGUMENT; + pcb = thread->pcb; addr = 0; size = 0; -- cgit v1.2.3