From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6534137F8DF for ; Fri, 8 May 2026 16:24:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778257444; cv=none; b=hD1YcsaI4FFb//GzBma52RJR+z7vk6Un407qZqaTquiIalMtmQw/9FDR6gxFMDsotQxadY4q8azo1lOvwgd+g5Y7ATSVtJDh95FLHsrQ0AaixEWpTVvTq5YVzV0iF2PSEreNcC3rrYCHyP1yBTwOVsijD08XrV7QkCCB7gI/8uQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778257444; c=relaxed/simple; bh=YO55I0yn0I6BsYQRV+sPGwF7VaB+Agwv5B9KA1bPS18=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DdIxzMGr5dVlwRXlKpx+K3DDPUtWdp5TPWKnNJzrIZ3xPxI2c98pzNzOM8a+7xdAv9Xj93VFO7cSye6qQnK9yNSq4pMMpgbbd7Oo5ha0lNZESevloO1aRAYI3QNV8RXIND0bsrvNUmpITyQS73srU98xLiKZyQ5JjHveLbEVwbk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=dz92HdUJ; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="dz92HdUJ" 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 71C5F1E7D; Fri, 8 May 2026 09:23:57 -0700 (PDT) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.96]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CED403F763; Fri, 8 May 2026 09:24:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1778257442; bh=YO55I0yn0I6BsYQRV+sPGwF7VaB+Agwv5B9KA1bPS18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dz92HdUJB0VlYOScG1Db+9H2H5xCh2I93kuH+gGn1hvKaOjIdkR1iEyWUw0ne5zOK 24JuBA9xceihx0hc9ANKtj3tOIOrXgA7qJp0DCT12eVogzlTqJqJP/ovoSyAHlEAFF rxY0vSlDj0NQzbMWY2V3THeS7AizCcwhDiX2rZ9E= From: James Morse 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 Message-ID: <20260508162341.3762549-3-james.morse@arm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260508162341.3762549-1-james.morse@arm.com> References: <20260508162341.3762549-1-james.morse@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit __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 --- 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