]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
arm_mpam: guard MBWU state before adding it to garbage
authorGuangshuo Li <lgs201920130244@gmail.com>
Wed, 8 Jul 2026 08:23:23 +0000 (16:23 +0800)
committerWill Deacon <will@kernel.org>
Thu, 16 Jul 2026 13:46:27 +0000 (14:46 +0100)
__destroy_component_cfg() adds each RIS mbwu_state object to the MPAM
garbage list when destroying component configuration.

However, mbwu_state is allocated per RIS and only for RISes with MBWU
monitors. A component can therefore have comp->cfg allocated while some
RISes still have ris->mbwu_state set to NULL.

Passing a NULL mbwu_state to add_to_garbage() dereferences the NULL
pointer inside the macro.

Skip RISes that do not have an mbwu_state object before adding them to
the garbage list.

Fixes: 41e8a14950e1 ("arm_mpam: Track bandwidth counter state for power management")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Reviewed-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>
drivers/resctrl/mpam_devices.c

index 8e48b918ae5407661d49c30d07ab12a495969b7d..2f09f4b78bd3bc4e759d014f2c94195dfe27ff29 100644 (file)
@@ -2612,8 +2612,10 @@ static void __destroy_component_cfg(struct mpam_component *comp)
                msc = vmsc->msc;
 
                if (mpam_mon_sel_lock(msc)) {
-                       list_for_each_entry(ris, &vmsc->ris, vmsc_list)
-                               add_to_garbage(ris->mbwu_state);
+                       list_for_each_entry(ris, &vmsc->ris, vmsc_list) {
+                               if (ris->mbwu_state)
+                                       add_to_garbage(ris->mbwu_state);
+                       }
                        mpam_mon_sel_unlock(msc);
                }
        }