[PATCH v2 07/12] arm_mpam: Initialize all of struct mon_read in mpam_restore_mbwu_state()

James Morse james.morse at arm.com
Fri Oct 2 08:15:46 PDT 2026


Hi Ben,

On 17/09/2026 15:56, Ben Horgan wrote:
> m->err and *m->val may be read before initialization in __ris_msmon_read()
> when called from mpam_restore_mbwu_state().
> 
> Initialize the whole struct mon_read in mpam_restore_mbwu_state() and fix
> the spelling of mbwu in the name.

> diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
> index 62562ce2f9aa..cdc2d9d19e19 100644
> --- a/drivers/resctrl/mpam_devices.c
> +++ b/drivers/resctrl/mpam_devices.c

> @@ -1672,14 +1672,17 @@ static int mpam_restore_mbwu_state(void *_ris)
>  			continue;
>  		}
>  
> -		mwbu_arg.ris = ris;
> -		mwbu_arg.ctx = &mbwu_state->cfg;
> -		mwbu_arg.type = mpam_msmon_choose_counter(class);
> -		mwbu_arg.val = &val;
> +		val = 0;
> +		mbwu_arg = (struct mon_read) {
> +			.ris = ris,
> +			.ctx = &mbwu_state->cfg,
> +			.type = mpam_msmon_choose_counter(class),
> +			.val = &val,
> +		};
>  
>  		mbwu_state->reset_on_next_read = true;
>  
> -		__ris_msmon_read_locked(&mwbu_arg);
> +		__ris_msmon_read_locked(&mbwu_arg);
>  
>  		mpam_mon_sel_unlock(msc);
>  	}


Reviewed-by: James Morse <james.morse at arm.com>


Thanks,

James



More information about the linux-arm-kernel mailing list