Re: [PATCH 0/2] Two x86 fixes

From: Ammar Faizi
Date: Tue Mar 01 2022 - 02:29:55 EST


On 3/1/22 2:23 PM, Ammar Faizi wrote:
[PATCH 1/2] x86/delay: Fix the wrong asm constraint in `delay_loop()`

@bp is a local variable, calling mce_threshold_remove_device() when
threshold_create_bank() fails will not free the @bp. Note that
mce_threshold_remove_device() frees the @bp only if it's already
stored in the @threshold_banks per-CPU variable.

At that point, the @threshold_banks per-CPU variable is still NULL,
so the mce_threshold_remove_device() will just be a no-op and the
@bp is leaked.

Fix this by calling kfree() and early returning when we fail.

This bug is introduced by commit 6458de97fc15530b544 ("x86/mce/amd:
Straighten CPU hotplug path") [1].

Link: https://lore.kernel.org/all/20200403161943.1458-6-bp@xxxxxxxxx [1]

Uhh... Wrong cover letter... Sorry... Re-sending now...

--
Ammar Faizi