* [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
@ 2026-09-02 14:37 Andre Przywara
2026-09-07 12:59 ` Ben Horgan
0 siblings, 1 reply; 3+ messages in thread
From: Andre Przywara @ 2026-09-02 14:37 UTC (permalink / raw)
To: James Morse, Ben Horgan
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin, Yin Li,
linux-arm-kernel, linux-kernel
get_cpu_cacheinfo_id() can fail, in which case it returns a negative
error value.
Check the returned value for this error condition, before passing the
value on to other code, which would hide the negative number in some high
value in the unsigned type.
Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/resctrl/mpam_resctrl.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 9d223057953ab..a5e661eff86d7 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
/* Find the L3 cache that has affinity with this CPU */
static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
{
- u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
+ int cache_id = get_cpu_cacheinfo_id(cpu, 3);
+
+ if (cache_id < 0)
+ return -ENOENT;
lockdep_assert_cpus_held();
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
2026-09-02 14:37 [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id() Andre Przywara
@ 2026-09-07 12:59 ` Ben Horgan
2026-09-07 13:14 ` Andre Przywara
0 siblings, 1 reply; 3+ messages in thread
From: Ben Horgan @ 2026-09-07 12:59 UTC (permalink / raw)
To: Andre Przywara, James Morse
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin, Yin Li,
linux-arm-kernel, linux-kernel
Hi Andre,
On 02/09/2026 15:37, Andre Przywara wrote:
> get_cpu_cacheinfo_id() can fail, in which case it returns a negative
> error value.
>
> Check the returned value for this error condition, before passing the
> value on to other code, which would hide the negative number in some high
> value in the unsigned type.
>
> Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
This looks good to me. Out of interest what led you to find this?
Reviewed-by: Ben Horgan <ben.horgan@arm.com>
Thanks,
Ben
> ---
> drivers/resctrl/mpam_resctrl.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
> index 9d223057953ab..a5e661eff86d7 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c
> @@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
> /* Find the L3 cache that has affinity with this CPU */
> static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
> {
> - u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
> + int cache_id = get_cpu_cacheinfo_id(cpu, 3);
> +
> + if (cache_id < 0)
> + return -ENOENT;
>
> lockdep_assert_cpus_held();
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
2026-09-07 12:59 ` Ben Horgan
@ 2026-09-07 13:14 ` Andre Przywara
0 siblings, 0 replies; 3+ messages in thread
From: Andre Przywara @ 2026-09-07 13:14 UTC (permalink / raw)
To: Ben Horgan, James Morse
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin, Yin Li,
linux-arm-kernel, linux-kernel
Hi Ben,
thanks for having a look!
On 9/7/26 14:59, Ben Horgan wrote:
> Hi Andre,
>
> On 02/09/2026 15:37, Andre Przywara wrote:
>> get_cpu_cacheinfo_id() can fail, in which case it returns a negative
>> error value.
>>
>> Check the returned value for this error condition, before passing the
>> value on to other code, which would hide the negative number in some high
>> value in the unsigned type.
>>
>> Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>
> This looks good to me. Out of interest what led you to find this?
For Yin Li's RFC patch [06/15], I was looking around to find the proper
type for cache-id, and stumbled upon this.
> Reviewed-by: Ben Horgan <ben.horgan@arm.com>
Thanks!
Cheers,
Andre
>
> Thanks,
>
> Ben
>
>> ---
>> drivers/resctrl/mpam_resctrl.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
>> index 9d223057953ab..a5e661eff86d7 100644
>> --- a/drivers/resctrl/mpam_resctrl.c
>> +++ b/drivers/resctrl/mpam_resctrl.c
>> @@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
>> /* Find the L3 cache that has affinity with this CPU */
>> static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
>> {
>> - u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
>> + int cache_id = get_cpu_cacheinfo_id(cpu, 3);
>> +
>> + if (cache_id < 0)
>> + return -ENOENT;
>>
>> lockdep_assert_cpus_held();
>>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-07 13:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-02 14:37 [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id() Andre Przywara
2026-09-07 12:59 ` Ben Horgan
2026-09-07 13:14 ` Andre Przywara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox