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 E2D663EDE46 for ; Wed, 8 Jul 2026 09:13:13 +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=1783501995; cv=none; b=je8EUIQ9klZkotvDLzceWuH2uh2xpne0LVuzQho0VPLXaer//cOb0mYnEBbp4kbu0aI1E2k9kt5m+7cAZ+C1+sK8/47DkMvl8ZFo/zkKgeOZ+xcV7gH/+B0xVKiRFfbYCWebGGrLYsEYooYuIEe7jRYSzDXsDjsiKefI1suZzxU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783501995; c=relaxed/simple; bh=inP2XWRuti91BcxDq2semgzYyN8xaAIKz8terxc8VCI=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=gB2Rc2rWUmlioMf/sAYyeHZHJuiYB5ATIUzz9Fe4NdhNY0VHjk8BbkULqclqvO/dTPq3tcZ/MJiB7H75ZxuXgemIpgSGe5/2BXfC/8V9q1/pBWGAxCwcpXCgNqQezwezIhJeQh1qBj85HQ8WMowhcxLvOqzNQ3SeYn0XE3nWLv0= 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=Di9zF+tS; 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="Di9zF+tS" 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 EF6421E5E; Wed, 8 Jul 2026 02:13:08 -0700 (PDT) Received: from [10.2.212.8] (e134344.arm.com [10.2.212.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 596113F85F; Wed, 8 Jul 2026 02:13:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1783501993; bh=inP2XWRuti91BcxDq2semgzYyN8xaAIKz8terxc8VCI=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Di9zF+tSQq845lHtQnsTproVwgAEKGxhr2ZvGKiO6CMlZlBORyFFh9+UJLDLqdwET AFvvvxvl/NxNpySztUyROZnKTamyjtEZiB4mB6FHkTS/B9+kVuQuoU5AQ8X96B7a8a cqBe0wuBm+aRYUFZwioleu+r4G76pO8wjxU1UwYM= Message-ID: Date: Wed, 8 Jul 2026 10:13:04 +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] arm_mpam: guard MBWU state before adding it to garbage To: Guangshuo Li , James Morse , Reinette Chatre , Fenghua Yu , Catalin Marinas , Shaopeng Tan , Zeng Heng , linux-kernel@vger.kernel.org References: <20260708082323.736350-1-lgs201920130244@gmail.com> Content-Language: en-US From: Ben Horgan In-Reply-To: <20260708082323.736350-1-lgs201920130244@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Guangshuo, On 7/8/26 09:23, Guangshuo Li wrote: > __destroy_component_cfg() adds each RIS mbwu_state object to the MPAM > garbage list when destroying component configuration. > > However, mbwu_state is allocated per RIS and only for RISes with MBWU > monitors. A component can therefore have comp->cfg allocated while some > RISes still have ris->mbwu_state set to NULL. > > Passing a NULL mbwu_state to add_to_garbage() dereferences the NULL > pointer inside the macro. > > Skip RISes that do not have an mbwu_state object before adding them to > the garbage list. > > Fixes: 41e8a14950e1 ("arm_mpam: Track bandwidth counter state for power management") > Signed-off-by: Guangshuo Li Good spot and thanks for the fix. Reviewed-by: Ben Horgan > --- > drivers/resctrl/mpam_devices.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c > index b69f99488111..59225694255f 100644 > --- a/drivers/resctrl/mpam_devices.c > +++ b/drivers/resctrl/mpam_devices.c > @@ -2606,8 +2606,10 @@ static void __destroy_component_cfg(struct mpam_component *comp) > msc = vmsc->msc; > > if (mpam_mon_sel_lock(msc)) { > - list_for_each_entry(ris, &vmsc->ris, vmsc_list) > - add_to_garbage(ris->mbwu_state); > + list_for_each_entry(ris, &vmsc->ris, vmsc_list) { > + if (ris->mbwu_state) > + add_to_garbage(ris->mbwu_state); > + } > mpam_mon_sel_unlock(msc); > } > }