Re: [PATCH 4/6] misc: ibmvmc: initialize HMC state before device registration

From: Greg Kroah-Hartman

Date: Wed Oct 28 2026 - 06:08:14 EST


On Wed, Oct 28, 2026 at 12:48:24PM +0800, Jiale Yao wrote:
> misc_register() exposes the IBM VMC device before the HMC state and
> spinlocks are initialized. A userspace operation racing module
> initialization can therefore access an HMC through an uninitialized
> spinlock.
>
> Initialize all HMC state before registering the misc device.
>
> Fixes: 0eca353e7ae7 ("misc: IBM Virtual Management Channel Driver (VMC)")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
> ---
> drivers/misc/ibmvmc.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/misc/ibmvmc.c b/drivers/misc/ibmvmc.c
> index 6afef0788b90..d03aeb8dea8f 100644
> --- a/drivers/misc/ibmvmc.c
> +++ b/drivers/misc/ibmvmc.c
> @@ -2366,14 +2366,6 @@ static int __init ibmvmc_module_init(void)
> ibmvmc.state = ibmvmc_state_initial;
> pr_info("ibmvmc: version %s\n", IBMVMC_DRIVER_VERSION);
>
> - rc = misc_register(&ibmvmc_miscdev);
> - if (rc) {
> - pr_err("ibmvmc: misc registration failed\n");
> - goto misc_register_failed;
> - }
> - pr_info("ibmvmc: node %d:%d\n", MISC_MAJOR,
> - ibmvmc_miscdev.minor);
> -
> /* Initialize data structures */
> memset(hmcs, 0, sizeof(struct ibmvmc_hmc) * MAX_HMCS);
> for (i = 0; i < MAX_HMCS; i++) {
> @@ -2383,6 +2375,14 @@ static int __init ibmvmc_module_init(void)
> hmcs[i].queue_outbound_msgs[j] = VMC_INVALID_BUFFER_ID;
> }
>
> + rc = misc_register(&ibmvmc_miscdev);
> + if (rc) {
> + pr_err("ibmvmc: misc registration failed\n");
> + goto misc_register_failed;
> + }
> + pr_info("ibmvmc: node %d:%d\n", MISC_MAJOR,
> + ibmvmc_miscdev.minor);

Note, when drivers are successful, they are quiet, so this can go away
with an add-on patch.

thanks,

greg k-h