Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87D593B8409; Mon, 17 Aug 2026 14:28:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786976892; cv=none; b=jSUMS/F0mvdnr4WyhXv3BZXEhJEWM/xYlD3Z7Q83Zs/h/Mh3Z5HNae8ZpHB4Ks6Sx1h8Z6v4HeVIImLlgmKfRpZ1hej2bXgHCSWUUZGJDZMXyGYNcukbT07HO9gNlt5blfTdEcWqqZYFtyd/Ut71k9K9LrrlAUl7NiRTKgr3EKg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786976892; c=relaxed/simple; bh=a3kkt7tmSY5lqHCZZNzuhJPzdvxZHcyS7xr6JtQFgu0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OjUyXLFINK4RhsyJhbpCQmAQtfM8Z6f0fmQJZRpNCqKClnFKNhSk3tVI6Y9CM0bmmyMVDwmiyxLAc2le8CAk2uPBaLrnXH2c0EcmT4Hy7bXQ6CCjEYDq2EolaJio5OEv5q7ZDP7DijVgWGtPA4Um2OPa04C7anTGobXxXQUccRs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dy5ec2ip; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="dy5ec2ip" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96DE51F000E9; Mon, 17 Aug 2026 14:28:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786976891; bh=dFYNsxWqWxa5oCNBfMHwG60Ap3Zr1SHwC/bPmTgOeoc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dy5ec2ip9j/YHai5FRLLRlY4xWeW8UT8ahVFGLrz1bQ7FD0XvEBV5SDhnPcpjtTVo RgkMO32emR1dHnsDSu87P43hehT0HjLssxO99EE2laCITm7xvhRersmktOcr/Snt8C HYWVPRn1NEDFsoXADaoNMtX1obdjpq7n8LFHNj0o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ruoyu Wang , Simon Horman , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 103/456] nfp: Check resource mutex allocation Date: Mon, 17 Aug 2026 15:28:13 +0200 Message-ID: <20260817132544.123792535@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132539.792407575@linuxfoundation.org> References: <20260817132539.792407575@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ruoyu Wang [ Upstream commit a61b4db34a753bdf5c9e77a7f3d3dddd41dcfacc ] nfp_cpp_resource_find() allocates a CPP mutex handle for the matching resource-table entry and then reports success. nfp_resource_try_acquire() immediately passes that handle to nfp_cpp_mutex_trylock(). However, nfp_cpp_mutex_alloc() returns NULL on failure. If that happens for a matching table entry, the resource lookup still returns success and the following trylock dereferences a NULL mutex pointer while opening the resource. nfp_resource_acquire() already treats failure to allocate the table mutex as -ENOMEM. Do the same for the resource mutex and fail the lookup before publishing the rest of the resource handle. This issue was found by a static analysis checker and confirmed by manual source review. Fixes: f01a2161577d ("nfp: add support for resources") Signed-off-by: Ruoyu Wang Reviewed-by: Simon Horman Link: https://patch.msgid.link/20260708143408.3168425-1-ruoyuw560@gmail.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c index ce7492a6a98fad..908d99f398b819 100644 --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c @@ -96,6 +96,9 @@ static int nfp_cpp_resource_find(struct nfp_cpp *cpp, struct nfp_resource *res) res->mutex = nfp_cpp_mutex_alloc(cpp, NFP_RESOURCE_TBL_TARGET, addr, key); + if (!res->mutex) + return -ENOMEM; + res->cpp_id = NFP_CPP_ID(entry.region.cpp_target, entry.region.cpp_action, entry.region.cpp_token); -- 2.53.0