linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/resctrl: Fix potential memory leak
@ 2019-12-19 22:38 Shakeel Butt
  2019-12-19 23:02 ` Fenghua Yu
  2019-12-19 23:26 ` Reinette Chatre
  0 siblings, 2 replies; 5+ messages in thread
From: Shakeel Butt @ 2019-12-19 22:38 UTC (permalink / raw)
  To: Fenghua Yu, Reinette Chatre
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86, linux-kernel,
	Shakeel Butt

The set_cache_qos_cfg() is leaking memory when the given level is not
RDT_RESOURCE_L3 or RDT_RESOURCE_L2. Fix that.

Fixes: 99adde9b370de ("x86/intel_rdt: Enable L2 CDP in MSR IA32_L2_QOS_CFG")
Signed-off-by: Shakeel Butt <shakeelb@google.com>
---
 arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 2e3b06d6bbc6..a0c279c7f4b9 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -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) {
-- 
2.24.1.735.g03f4e72817-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/resctrl: Fix potential memory leak
  2019-12-19 22:38 [PATCH] x86/resctrl: Fix potential memory leak Shakeel Butt
@ 2019-12-19 23:02 ` Fenghua Yu
  2019-12-19 23:26 ` Reinette Chatre
  1 sibling, 0 replies; 5+ messages in thread
From: Fenghua Yu @ 2019-12-19 23:02 UTC (permalink / raw)
  To: Shakeel Butt
  Cc: Reinette Chatre, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	x86, linux-kernel

On Thu, Dec 19, 2019 at 02:38:34PM -0800, Shakeel Butt wrote:
> The set_cache_qos_cfg() is leaking memory when the given level is not
> RDT_RESOURCE_L3 or RDT_RESOURCE_L2. Fix that.
> 
> Fixes: 99adde9b370de ("x86/intel_rdt: Enable L2 CDP in MSR IA32_L2_QOS_CFG")
> Signed-off-by: Shakeel Butt <shakeelb@google.com>

Acked-by: Fenghua Yu <fenghua.yu@intel.com>

Thanks.

-Fenghua

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/resctrl: Fix potential memory leak
  2019-12-19 22:38 [PATCH] x86/resctrl: Fix potential memory leak Shakeel Butt
  2019-12-19 23:02 ` Fenghua Yu
@ 2019-12-19 23:26 ` Reinette Chatre
  2019-12-20  1:54   ` Shakeel Butt
  1 sibling, 1 reply; 5+ messages in thread
From: Reinette Chatre @ 2019-12-19 23:26 UTC (permalink / raw)
  To: Shakeel Butt, Fenghua Yu
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86, linux-kernel

Hi Shakeel,

On 12/19/2019 2:38 PM, Shakeel Butt wrote:
> The set_cache_qos_cfg() is leaking memory when the given level is not
> RDT_RESOURCE_L3 or RDT_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.

> 
> Fixes: 99adde9b370de ("x86/intel_rdt: Enable L2 CDP in MSR IA32_L2_QOS_CFG")
> Signed-off-by: Shakeel Butt <shakeelb@google.com>
> ---
>  arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index 2e3b06d6bbc6..a0c279c7f4b9 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -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) {
> 

Reinette

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/resctrl: Fix potential memory leak
  2019-12-19 23:26 ` Reinette Chatre
@ 2019-12-20  1:54   ` Shakeel Butt
  2019-12-20  5:46     ` Reinette Chatre
  0 siblings, 1 reply; 5+ messages in thread
From: Shakeel Butt @ 2019-12-20  1:54 UTC (permalink / raw)
  To: Reinette Chatre
  Cc: Fenghua Yu, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86, LKML

On Thu, Dec 19, 2019 at 3:27 PM Reinette Chatre
<reinette.chatre@intel.com> wrote:
>
> Hi Shakeel,
>
> On 12/19/2019 2:38 PM, Shakeel Butt wrote:
> > The set_cache_qos_cfg() is leaking memory when the given level is not
> > RDT_RESOURCE_L3 or RDT_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.
>

Do you want me to add that info the commit and resend the v2 of the patch?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/resctrl: Fix potential memory leak
  2019-12-20  1:54   ` Shakeel Butt
@ 2019-12-20  5:46     ` Reinette Chatre
  0 siblings, 0 replies; 5+ messages in thread
From: Reinette Chatre @ 2019-12-20  5:46 UTC (permalink / raw)
  To: Shakeel Butt
  Cc: Fenghua Yu, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86, LKML

Hi Shakeel,

On 12/19/2019 5:54 PM, Shakeel Butt wrote:
> On Thu, Dec 19, 2019 at 3:27 PM Reinette Chatre
> <reinette.chatre@intel.com> wrote:
>> On 12/19/2019 2:38 PM, Shakeel Butt wrote:
>>> The set_cache_qos_cfg() is leaking memory when the given level is not
>>> RDT_RESOURCE_L3 or RDT_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.
>>
> 
> Do you want me to add that info the commit and resend the v2 of the patch?
> 

Yes please.

Thank you very much

Reinette

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-20  5:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-19 22:38 [PATCH] x86/resctrl: Fix potential memory leak Shakeel Butt
2019-12-19 23:02 ` Fenghua Yu
2019-12-19 23:26 ` Reinette Chatre
2019-12-20  1:54   ` Shakeel Butt
2019-12-20  5:46     ` Reinette Chatre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).