From: James Morse <james.morse@arm.com>
To: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, zengheng4@huawei.com
Cc: wangkefeng.wang@huawei.com, xry111@xry111.site,
catalin.marinas@arm.com, yang@os.amperecomputing.com,
reinette.chatre@intel.com, will@kernel.org, thuth@redhat.com,
ben.horgan@arm.com, mrigendra.chaubey@gmail.com,
fenghuay@nvidia.com, ahmed.genidi@arm.com
Subject: [PATCH v3 2/4] arm_mpam: Check whether the config array is allocated before destroying it
Date: Fri, 8 May 2026 17:23:39 +0100 [thread overview]
Message-ID: <20260508162341.3762549-3-james.morse@arm.com> (raw)
In-Reply-To: <20260508162341.3762549-1-james.morse@arm.com>
__destroy_component_cfg() is called to free the configuration array.
It uses the embedded 'garbage' structure, which means the array has
to be allocated.
If __destroy_component_cfg() is called from mpam_disable() before the
configuration was ever allocated, then a NULL pointer is dereferenced.
Check for this case and return early if the configuration is not
allocated.
__destroy_component_cfg() also frees the mbwu_state as this is allocated
by __allocate_component_cfg(). As the mbwu_state is allocated after
comp->cfg is set, and is also under mpam_list_lock, only the first
pointer needs checking.
Fixes: 3bd04fe7d807bb ("arm_mpam: Extend reset logic to allow devices to be reset any time")
Signed-off-by: James Morse <james.morse@arm.com>
---
drivers/resctrl/mpam_devices.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index bef5e9e9e844..916d8fd45ed5 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -2591,6 +2591,9 @@ static void __destroy_component_cfg(struct mpam_component *comp)
lockdep_assert_held(&mpam_list_lock);
+ if (!comp->cfg)
+ return;
+
add_to_garbage(comp->cfg);
list_for_each_entry(vmsc, &comp->vmsc, comp_list) {
msc = vmsc->msc;
--
2.53.0
next prev parent reply other threads:[~2026-05-08 16:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 16:23 [PATCH v3 0/4] arm_mpam: Add support for the MPAM v0.1 architecture version James Morse
2026-05-08 16:23 ` [PATCH v3 1/4] arm_mpam: Fix false positive assert failure during mpam_disable() James Morse
2026-05-11 11:19 ` Ben Horgan
2026-05-08 16:23 ` James Morse [this message]
2026-05-11 11:23 ` [PATCH v3 2/4] arm_mpam: Check whether the config array is allocated before destroying it Ben Horgan
2026-05-08 16:23 ` [PATCH v3 3/4] arm64: cpufeature: Add support for the MPAM v0.1 architecture version James Morse
2026-05-08 16:23 ` [PATCH v3 4/4] arm_mpam: Update architecture version check for MPAM MSC James Morse
2026-05-08 16:35 ` Ben Horgan
2026-05-09 6:26 ` Zeng Heng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260508162341.3762549-3-james.morse@arm.com \
--to=james.morse@arm.com \
--cc=ahmed.genidi@arm.com \
--cc=ben.horgan@arm.com \
--cc=catalin.marinas@arm.com \
--cc=fenghuay@nvidia.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mrigendra.chaubey@gmail.com \
--cc=reinette.chatre@intel.com \
--cc=thuth@redhat.com \
--cc=wangkefeng.wang@huawei.com \
--cc=will@kernel.org \
--cc=xry111@xry111.site \
--cc=yang@os.amperecomputing.com \
--cc=zengheng4@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox