x86/resctrl: Fix potential memory leak
Subsystems (2)
PATCH 1/1 x86/resctrl: Fix potential memory leak
The set_cache_qos_cfg() is leaking memory when the given level is not RDT_RESOURCE_L3 or RDT_RESOURCE_L2. Fix that.
--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3 -1
@@ -1748,8 +1748,10 @@ static int set_cache_qos_cfg(int level, bool enable) update = l3_qos_cfg_update; else if (level == RDT_RESOURCE_L2) update = l2_qos_cfg_update; - else + else { +free_cpumask_var (cpu_mask);return -EINVAL ; + } r_l = &rdt_resources_all[level];list_for_each_entry (d, &r_l->domains, list) {
Signature · 1 line
2.24.1.735.g03f4e72817-goog
Quoted 5 lines · Shakeel Butt
The
set_cache_qos_cfg()is leaking memory when the given level is notRDT_RESOURCE_L3orRDT_RESOURCE_L2. Fix that.Fixes 99adde9b370de ("x86/intel_rdt: Enable L2 CDP in MSR IA32_L2_QOS_CFG")Signed-off-by Shakeel Butt <[email protected]>
Thanks.
-Fenghua
Reinette Chatre
maintainerHi Shakeel,
Quoted 2 lines · Shakeel Butt
The
set_cache_qos_cfg()is leaking memory when the given level is notRDT_RESOURCE_L3orRDT_RESOURCE_L2. Fix that.
I think it would be valuable to those considering whether they need to backport to know that RDT_RESOURCE_L3 and RDT_RESOURCE_L2 are currently the only possible levels with which this function is called. It is thus not currently possible for this leak to occur. Indeed a valuable safety to add in case this code may change in the future. Thank you very much.
Quoted 14 lines
Fixes 99adde9b370de ("x86/intel_rdt: Enable L2 CDP in MSR IA32_L2_QOS_CFG")Signed-off-by Shakeel Butt <[email protected]>--- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -1748,8 +1748,10 @@ static int set_cache_qos_cfg(int level, bool enable) update = l3_qos_cfg_update;
arch/x86/kernel/cpu/resctrl/rdtgroup.c static int set_cache_qos_cfg(int level, bool enable) · line 1757
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +3
-1else if (level ==RDT_RESOURCE_L2 ) update = l2_qos_cfg_update; -else +else { +free_cpumask_var (cpu_mask);return -EINVAL ; + } r_l = &rdt_resources_all[level];list_for_each_entry (d, &r_l->domains, list) {
Reinette
Quoted 4 lines · Reinette Chatre
Hi Shakeel,
On 12/19/2019 2:38 PM, Shakeel Butt wrote:
Quoted 9 lines
Quoted 2 lines
The
set_cache_qos_cfg()is leaking memory when the given level is notRDT_RESOURCE_L3orRDT_RESOURCE_L2. Fix that.I think it would be valuable to those considering whether they need to backport to know that
RDT_RESOURCE_L3andRDT_RESOURCE_L2are currently the only possible levels with which this function is called. It is thus not currently possible for this leak to occur. Indeed a valuable safety to add in case this code may change in the future. Thank you very much.
Do you want me to add that info the commit and resend the v2 of the patch?
Reinette Chatre
maintainerHi Shakeel,
Quoted 6 lines · Shakeel Butt
Quoted 4 lines · Reinette Chatre
Quoted 2 lines · Shakeel Butt
The
set_cache_qos_cfg()is leaking memory when the given level is notRDT_RESOURCE_L3orRDT_RESOURCE_L2. Fix that.
Quoted 9 lines
Quoted 6 lines
I think it would be valuable to those considering whether they need to backport to know that
RDT_RESOURCE_L3andRDT_RESOURCE_L2are currently the only possible levels with which this function is called. It is thus not currently possible for this leak to occur. Indeed a valuable safety to add in case this code may change in the future. Thank you very much.Do you want me to add that info the commit and resend the v2 of the patch?
Yes please.
Thank you very much
Reinette