Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1367307pxb; Fri, 1 Oct 2021 09:09:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpRIZWQdrRZQ+oLlxkeVSusC1K1rBVbojXVlJRNqjb/2B5NypzLExMW0JE8S5Qhx/x5Idg X-Received: by 2002:a17:903:246:b0:13a:22d1:88b with SMTP id j6-20020a170903024600b0013a22d1088bmr10246087plh.16.1633104599479; Fri, 01 Oct 2021 09:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633104599; cv=none; d=google.com; s=arc-20160816; b=boyTf8pMTmfxOxqcUDBEbVKKDAubuAnyPA5iRfvBgatIVkOllnEQou6azfY08R7ik7 upvKML4uWj/3okGwrY1dK3x7G48fSh5QbfMTy/ZIJLBBLAGlSos2BCmnJCD0V6tt2Slo +hcuuPcM7VnRNtJ/630KWqnOLInm9fdICZrmOfkGCU7n57qS/5sXNgrJXwUgmXsgr3QJ BMYmCHFoZdMJiD28e+M6LsQR5kWeACfLkzAqWISPLlTBIp6RwBv5WcOGT/R5iYNOh5Yl u5uM/7/CdF8woI680D933HJE+yioGeqs1H4ONMV4PYL0SjF5iD+XmHDKUW1R2VldpVyU E9GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fddsTYk4hphNIuvMUkbclqBYxx6Fgyyewfg1BjAjKZA=; b=oSbERjI0AzdjqzAVuchtmL71Icf0ukmI6EgsjCJNLElQE1h/YJycszC07memcxN4a/ RzaGTbulNvSpxprCQDjeQ0m25XQiF3G0X4KR2ISNwY0MVIzYduNn9BiWpFDfhX3PrOM9 L3AR0t2wm4zgUdCj9bSegF11ZIWM7CM9LpqyFW2l/20kVf4+FqjpspNeiV6ueMVBqwRd auE3LOcg60EyZJvFOvQNP3jmqHcppLUDuBB9qsafK3bRN+dqhHVUIlG65BGDqYMohgqE lmLUbioIO6nKi0oBYtEp5Mw8+ZQfsGTcHqaynsbCvk3GbL/0l8KOrOXve4oHFZ1yMDXC ovzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx12si1658625pjb.172.2021.10.01.09.09.45; Fri, 01 Oct 2021 09:09:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355205AbhJAQFL (ORCPT + 99 others); Fri, 1 Oct 2021 12:05:11 -0400 Received: from foss.arm.com ([217.140.110.172]:46356 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355206AbhJAQFL (ORCPT ); Fri, 1 Oct 2021 12:05:11 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D4528113E; Fri, 1 Oct 2021 09:03:26 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D7B683F766; Fri, 1 Oct 2021 09:03:24 -0700 (PDT) From: James Morse To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , James Morse , shameerali.kolothum.thodi@huawei.com, Jamie Iles , D Scott Phillips OS , lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com Subject: [PATCH v2 01/23] x86/resctrl: Free the ctrlval arrays when domain_setup_mon_state() fails Date: Fri, 1 Oct 2021 16:02:40 +0000 Message-Id: <20211001160302.31189-2-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211001160302.31189-1-james.morse@arm.com> References: <20211001160302.31189-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org domain_add_cpu() is called whenever a CPU is brought online. The earlier call to domain_setup_ctrlval() allocates the control value arrays. If domain_setup_mon_state() fails, the control value arrays are not freed. Add the missing kfree() calls. Fixes: 1bd2a63b4f0de ("x86/intel_rdt/mba_sc: Add initialization support") Fixes: edf6fa1c4a951 ("x86/intel_rdt/cqm: Add RMID (Resource monitoring ID) management") Acked-by: Reinette Chatre Signed-off-by: James Morse --- This will not apply prior to v5.15-rc1, I'll provide a backport. ~s/hw_dom/d/; --- arch/x86/kernel/cpu/resctrl/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 4b8813bafffd..b5de5a6c115c 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -532,6 +532,8 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r) } if (r->mon_capable && domain_setup_mon_state(r, d)) { + kfree(hw_dom->ctrl_val); + kfree(hw_dom->mbps_val); kfree(d); return; } -- 2.30.2