From mboxrd@z Thu Jan 1 00:00:00 1970 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 928E2446821; Thu, 30 Jul 2026 16:03:08 +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=1785427389; cv=none; b=t+3kEC0TVYIQW3qNk4D29jjXUySapx30JYyfBAA3APRTecsguMiLUE31nT+cOrWRJANk5FxS4aBBJq2IGsOxwaJW2GM2nee68slc6jbQVOAINWCpiSKNDK4YedcOemj1QKwsez4w4dDRayfNM5UYG1/BuLb2wLtXQwgLIeo7RWc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785427389; c=relaxed/simple; bh=CJghthWmeKDGgSazCvE42gBki7TAOpNKwGtxYyW9zns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fUg8ZFYIhP0WjYpY0wWQhmfwnMeBbM2z8aC1AFVw6oE2z2mfEyELlatnZuDUy1RMMYJ8TzTzkcHC1mG8i4uiR8CQIB0uIrZEs5wScWY0GyBKb2aZT40Rri0ZOV5uBmJxBtX3cHomfnXbyBvbii9aH1yCYy1FVRz1qkb5QPCa8wI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=t9a93QOF; 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="t9a93QOF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEF1C1F000E9; Thu, 30 Jul 2026 16:03:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785427388; bh=jFfqL8UPYY435mXrJFJwP1v77/W5v41DBHAcg73XwRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=t9a93QOFpW2IPxDRE0O5hwQicckHM13eQLiY4ah7OLe12Vryw3bUA3PPfmrpwf9Bx W1Z5EGHgabvqtDPQhnvyW3kJCgkBECg7hPTfBlEgeOTe3P5tFRl4XP73XbafSLy9Fp yKcol7pFu49RfO83jBd9PR2Qkm9od0wz/3tMeUKc= 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 6.6 153/484] nfp: Check resource mutex allocation Date: Thu, 30 Jul 2026 16:10:50 +0200 Message-ID: <20260730141426.786190681@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141423.392222816@linuxfoundation.org> References: <20260730141423.392222816@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 6.6-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