lkml.org 
[lkml]   [2020]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 4.19 15/56] x86/resctrl: Fix potential memory leak
    Date
    From: Shakeel Butt <shakeelb@google.com>

    [ Upstream commit ab6a2114433a3b5b555983dcb9b752a85255f04b ]

    set_cache_qos_cfg() is leaking memory when the given level is not
    RDT_RESOURCE_L3 or RDT_RESOURCE_L2. At the moment, this function is
    called with only valid levels but move the allocation after the valid
    level checks in order to make it more robust and future proof.

    [ bp: Massage commit message. ]

    Fixes: 99adde9b370de ("x86/intel_rdt: Enable L2 CDP in MSR IA32_L2_QOS_CFG")
    Signed-off-by: Shakeel Butt <shakeelb@google.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Cc: Fenghua Yu <fenghua.yu@intel.com>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Reinette Chatre <reinette.chatre@intel.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: x86-ml <x86@kernel.org>
    Link: https://lkml.kernel.org/r/20200102165844.133133-1-shakeelb@google.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 6 +++---
    1 file changed, 3 insertions(+), 3 deletions(-)

    diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
    index a2d7e6646cce8..841a0246eb897 100644
    --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
    +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
    @@ -1749,9 +1749,6 @@ static int set_cache_qos_cfg(int level, bool enable)
    struct rdt_domain *d;
    int cpu;

    - if (!zalloc_cpumask_var(&cpu_mask, GFP_KERNEL))
    - return -ENOMEM;
    -
    if (level == RDT_RESOURCE_L3)
    update = l3_qos_cfg_update;
    else if (level == RDT_RESOURCE_L2)
    @@ -1759,6 +1756,9 @@ static int set_cache_qos_cfg(int level, bool enable)
    else
    return -EINVAL;

    + if (!zalloc_cpumask_var(&cpu_mask, GFP_KERNEL))
    + return -ENOMEM;
    +
    r_l = &rdt_resources_all[level];
    list_for_each_entry(d, &r_l->domains, list) {
    /* Pick one CPU from each domain instance to update MSR */
    --
    2.20.1
    \
     
     \ /
      Last update: 2020-01-24 15:21    [W:3.735 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site