From: Hugh Dickins Date: Tue, 5 Dec 2017 04:13:35 +0000 (-0800) Subject: kaiser: fix unlikely error in alloc_ldt_struct() X-Git-Tag: archive/raspbian/4.9.80-2+rpi1~8^2^2~24 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4c725cb7331aa78e07c250d439cfadf25f625e1f;p=linux-4.9.git kaiser: fix unlikely error in alloc_ldt_struct() An error from kaiser_add_mapping() here is not at all likely, but Eric Biggers rightly points out that __free_ldt_struct() relies on new_ldt->size being initialized: move that up. Signed-off-by: Hugh Dickins Signed-off-by: Greg Kroah-Hartman Gbp-Pq: Topic features/all/kpti Gbp-Pq: Name kaiser-fix-unlikely-error-in-alloc_ldt_struct.patch --- diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c index 8331bad03938..536e6ab783cf 100644 --- a/arch/x86/kernel/ldt.c +++ b/arch/x86/kernel/ldt.c @@ -78,11 +78,11 @@ static struct ldt_struct *alloc_ldt_struct(int size) ret = kaiser_add_mapping((unsigned long)new_ldt->entries, alloc_size, __PAGE_KERNEL); + new_ldt->size = size; if (ret) { __free_ldt_struct(new_ldt); return NULL; } - new_ldt->size = size; return new_ldt; }