Re: [PATCH 09/13] x86/microcode: Add a generic mechanism to declare support for minrev

From: Huang, Kai
Date: Wed Oct 19 2022 - 00:06:42 EST


On Fri, 2022-10-14 at 13:09 -0700, Ashok Raj wrote:
> @@ -606,6 +606,7 @@ static ssize_t reload_store(struct device *dev,
>   enum ucode_state tmp_ret = UCODE_OK;
>   int bsp = boot_cpu_data.cpu_index;
>   unsigned long val;
> + int minrev;
>   ssize_t ret = 0;
>  
>   ret = kstrtoul(buf, 0, &val);
> @@ -621,8 +622,14 @@ static ssize_t reload_store(struct device *dev,
>   if (ret)
>   goto put;
>  
> - pr_err("Attempting late microcode loading - it is dangerous and taints the kernel.\n");
> - pr_err("You should switch to early loading, if possible.\n");
> + if (microcode_ops->check_minrev())
> + minrev = microcode_ops->check_minrev();
> +
> + if (!minrev) {
> + pr_err("Attempting late microcode loading - it is dangerous and taints the kernel.\n");
> + pr_err("You should switch to early loading, if possible.\n");
> + }
> +

Hi Ashok,

IIUC a variable in stack isn't initialized to 0 automatically. So looks if
check_minrev() callback is NULL, you will get an uninitialized 'minrev' in the
above if() statement check.

--
Thanks,
-Kai