Skip to content

Commit 82cd19c

Browse files
committed
Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: x86/microcode: Fix double vfree() and remove redundant pointer checks before vfree()
2 parents b52e2a6 + 5cdd2de commit 82cd19c

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

arch/x86/kernel/microcode_intel.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,7 @@ static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size,
364364

365365
/* For performance reasons, reuse mc area when possible */
366366
if (!mc || mc_size > curr_mc_size) {
367-
if (mc)
368-
vfree(mc);
367+
vfree(mc);
369368
mc = vmalloc(mc_size);
370369
if (!mc)
371370
break;
@@ -374,13 +373,11 @@ static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size,
374373

375374
if (get_ucode_data(mc, ucode_ptr, mc_size) ||
376375
microcode_sanity_check(mc) < 0) {
377-
vfree(mc);
378376
break;
379377
}
380378

381379
if (get_matching_microcode(&uci->cpu_sig, mc, new_rev)) {
382-
if (new_mc)
383-
vfree(new_mc);
380+
vfree(new_mc);
384381
new_rev = mc_header.rev;
385382
new_mc = mc;
386383
mc = NULL; /* trigger new vmalloc */
@@ -390,12 +387,10 @@ static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size,
390387
leftover -= mc_size;
391388
}
392389

393-
if (mc)
394-
vfree(mc);
390+
vfree(mc);
395391

396392
if (leftover) {
397-
if (new_mc)
398-
vfree(new_mc);
393+
vfree(new_mc);
399394
state = UCODE_ERROR;
400395
goto out;
401396
}
@@ -405,8 +400,7 @@ static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size,
405400
goto out;
406401
}
407402

408-
if (uci->mc)
409-
vfree(uci->mc);
403+
vfree(uci->mc);
410404
uci->mc = (struct microcode_intel *)new_mc;
411405

412406
pr_debug("CPU%d found a matching microcode update with version 0x%x (current=0x%x)\n",

0 commit comments

Comments
 (0)