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 0FD8136C0CA for ; Mon, 11 May 2026 11:23:19 +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=1778498601; cv=none; b=rIXuG5//EIjl4Y9HZ08t/6ETEqkBGP6HAGo90A4Mq6vEh89K1HNBBvwIz890eWZTyQDOQNeq0Y1wBw321QDDMQFYbJBiDZBjj6HrZ8CPrIguu4NoQAEWvjDH4luSBmnprr3pCTDWLwySDitc5fXo2zOZiuOytVr0SaMvToaCQ+E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778498601; c=relaxed/simple; bh=ujSNN5cWvyVF4S7u0xQhZ8A7OACXeRpz8CHJJ9Km52s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eaRMiB2pnOYmFXsq8dUszNNST0fAqK8CKASg2c7Sz8KRYjfGQMC0gmyJMVBNGdnZ44hTzDnFXaso68ylY2qvu282H3q2nv3fU1yowZZ+UGdgjzM44KwWEt0fbooZCIfB0JDoaQlFZnYa59I3HjIhmFpndcvVY5zYDF9/E/43O+4= 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=ExM/W6Gg; 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="ExM/W6Gg" 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 365ED1595; Mon, 11 May 2026 04:23:14 -0700 (PDT) Received: from [10.1.196.46] (e134344.arm.com [10.1.196.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA0623F85F; Mon, 11 May 2026 04:23:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1778498599; bh=ujSNN5cWvyVF4S7u0xQhZ8A7OACXeRpz8CHJJ9Km52s=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ExM/W6Gg77bcfApdpGJciBaAvdH7139GgDEcOofjZbg2BSobdkpa4CNZbzyPQlc6E 9NkzY+NMBULB3Ek4UkLc52PczZaYW42DWOt9c6dV4tjr2tMGlSxHAFyX5+is8jC1dY X01tGcetMpeqR+habgv5l96Rjlw+ea4Rt4mn4h1Q= Message-ID: <043ecb1b-6c22-460a-bacc-e853b45c5808@arm.com> Date: Mon, 11 May 2026 12:23:16 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Thunderbird Daily Subject: Re: [PATCH v3 2/4] arm_mpam: Check whether the config array is allocated before destroying it To: James Morse , 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, mrigendra.chaubey@gmail.com, fenghuay@nvidia.com, ahmed.genidi@arm.com References: <20260508162341.3762549-1-james.morse@arm.com> <20260508162341.3762549-3-james.morse@arm.com> Content-Language: en-US From: Ben Horgan In-Reply-To: <20260508162341.3762549-3-james.morse@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi James, On 5/8/26 17:23, James Morse wrote: > __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 I checked on the FVP and with this and the previous patch and an early mpam_disable due to an unsupported MSC version doesn't cause any problems. Additionally, the kunit tests still run and pass. Reviewed-by: Ben Horgan Thanks, Ben