Module Name: src Committed By: mrg Date: Sun Oct 4 17:52:50 UTC 2015
Modified Files: src/sys/arch/x86/x86: cpu_ucode_intel.c Log Message: kmem_free() the address returned by kmem_alloc(). found by Brainy. use the newly aligned location if we needed it. found by kre. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/x86/cpu_ucode_intel.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x86/x86/cpu_ucode_intel.c diff -u src/sys/arch/x86/x86/cpu_ucode_intel.c:1.8 src/sys/arch/x86/x86/cpu_ucode_intel.c:1.9 --- src/sys/arch/x86/x86/cpu_ucode_intel.c:1.8 Tue May 12 00:00:35 2015 +++ src/sys/arch/x86/x86/cpu_ucode_intel.c Sun Oct 4 17:52:50 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_ucode_intel.c,v 1.8 2015/05/12 00:00:35 msaitoh Exp $ */ +/* $NetBSD: cpu_ucode_intel.c,v 1.9 2015/10/04 17:52:50 mrg Exp $ */ /* * Copyright (c) 2012 The NetBSD Foundation, Inc. * All rights reserved. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.8 2015/05/12 00:00:35 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_ucode_intel.c,v 1.9 2015/10/04 17:52:50 mrg Exp $"); #include "opt_xen.h" #include "opt_cpu_ucode.h" @@ -111,6 +111,7 @@ cpu_ucode_intel_apply(struct cpu_ucode_s uint32_t ucodetarget, oucodeversion, nucodeversion; int platformid; struct intel1_ucode_header *uh; + void *uha; size_t newbufsize = 0; int rv = 0; @@ -126,12 +127,12 @@ cpu_ucode_intel_apply(struct cpu_ucode_s if ((uintptr_t)(sc->sc_blob) & 15) { /* Make the buffer 16 byte aligned */ newbufsize = sc->sc_blobsize + 15; - uh = kmem_alloc(newbufsize, KM_SLEEP); - if (uh == NULL) { + uha = kmem_alloc(newbufsize, KM_SLEEP); + if (uha == NULL) { printf("%s: memory allocation failed\n", __func__); return EINVAL; } - uh = (struct intel1_ucode_header *)roundup2((uintptr_t)uh, 16); + uh = (struct intel1_ucode_header *)roundup2((uintptr_t)uha, 16); /* Copy to the new area */ memcpy(uh, sc->sc_blob, sc->sc_blobsize); } @@ -144,7 +145,7 @@ cpu_ucode_intel_apply(struct cpu_ucode_s rv = EEXIST; /* ??? */ goto out; } - wrmsr(MSR_BIOS_UPDT_TRIG, (uintptr_t)(sc->sc_blob) + 48); + wrmsr(MSR_BIOS_UPDT_TRIG, (uintptr_t)uh + 48); intel_getcurrentucode(&nucodeversion, &platformid); kpreempt_enable(); @@ -158,7 +159,7 @@ cpu_ucode_intel_apply(struct cpu_ucode_s oucodeversion, nucodeversion); out: if (newbufsize != 0) - kmem_free(uh, newbufsize); + kmem_free(uha, newbufsize); return rv; } #endif /* ! XEN */