aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Petkov <borislav.petkov@amd.com>2010-12-30 15:06:01 -0500
committerBorislav Petkov <borislav.petkov@amd.com>2011-02-09 10:05:32 -0500
commitffc7e8ac820bf9dd6106b01d3e64fecb5177cf43 (patch)
tree50bf8031403e4b6da2f24aec3f85747ce3eed003
parent6c53cbfced048c421e4f72cb2183465f68fbc5e7 (diff)
x86, microcode, AMD: Release firmware on error
When the ucode magic is wrong, for whatever reason, we don't release the loaded firmware binary and its related resources. Make sure we do. Also, fix function naming to fit this driver's convention and shorten variable names. Signed-off-by: Borislav Petkov <borislav.petkov@amd.com> Acked-by: Andreas Herrmann <Andreas.Herrmann3@amd.com>
-rw-r--r--arch/x86/kernel/microcode_amd.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index 0fe6d1a66c38..ef91df0fb64d 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -278,27 +278,29 @@ generic_load_microcode(int cpu, const u8 *data, size_t size)
278 return state; 278 return state;
279} 279}
280 280
281static enum ucode_state request_microcode_fw(int cpu, struct device *device) 281static enum ucode_state request_microcode_amd(int cpu, struct device *device)
282{ 282{
283 const char *fw_name = "amd-ucode/microcode_amd.bin"; 283 const char *fw_name = "amd-ucode/microcode_amd.bin";
284 const struct firmware *firmware; 284 const struct firmware *fw;
285 enum ucode_state ret; 285 enum ucode_state ret = UCODE_NFOUND;
286 286
287 if (request_firmware(&firmware, fw_name, device)) { 287 if (request_firmware(&fw, fw_name, device)) {
288 printk(KERN_ERR "microcode: failed to load file %s\n", fw_name); 288 printk(KERN_ERR "microcode: failed to load file %s\n", fw_name);
289 return UCODE_NFOUND; 289 goto out;
290 } 290 }
291 291
292 if (*(u32 *)firmware->data != UCODE_MAGIC) { 292 ret = UCODE_ERROR;
293 pr_err("invalid UCODE_MAGIC (0x%08x)\n", 293 if (*(u32 *)fw->data != UCODE_MAGIC) {
294 *(u32 *)firmware->data); 294 pr_err("Invalid UCODE_MAGIC (0x%08x)\n", *(u32 *)fw->data);
295 return UCODE_ERROR; 295 goto fw_release;
296 } 296 }
297 297
298 ret = generic_load_microcode(cpu, firmware->data, firmware->size); 298 ret = generic_load_microcode(cpu, fw->data, fw->size);
299 299
300 release_firmware(firmware); 300fw_release:
301 release_firmware(fw);
301 302
303out:
302 return ret; 304 return ret;
303} 305}
304 306
@@ -319,7 +321,7 @@ static void microcode_fini_cpu_amd(int cpu)
319 321
320static struct microcode_ops microcode_amd_ops = { 322static struct microcode_ops microcode_amd_ops = {
321 .request_microcode_user = request_microcode_user, 323 .request_microcode_user = request_microcode_user,
322 .request_microcode_fw = request_microcode_fw, 324 .request_microcode_fw = request_microcode_amd,
323 .collect_cpu_info = collect_cpu_info_amd, 325 .collect_cpu_info = collect_cpu_info_amd,
324 .apply_microcode = apply_microcode_amd, 326 .apply_microcode = apply_microcode_amd,
325 .microcode_fini_cpu = microcode_fini_cpu_amd, 327 .microcode_fini_cpu = microcode_fini_cpu_amd,