From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8822626FA5A; Wed, 8 Apr 2026 18:31:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775673070; cv=none; b=dRicL1xaCOaVo28iDugtQpxquSBJtXY9unmhCTvFS1GsSWXnhPZCMFX+3ca3bCI8VDS9yU94oGQdvbP9lpZNtXJer6rrS6BaMzGBf0UwTvkDnDrniymo7z58ABgQx+Mn0wtYCJBgXdXLMKRAmMSLQTnteY5mZWCmdtsNAAlIdvE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775673070; c=relaxed/simple; bh=rt/pYLBNJigFbQ0cPdeEp+KKg/f0N2ghn6uRtmuwRnA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XWtpt65oHo6lh5h8FEUunBvDm53sNtS6NT9fAdChFUzjHHG4nbdZsWCe6IxY68h+M331Gz3dn9af2qvw2SDgbippGrg3Xh71wo6eNiC1F+5vHMRYjHPWnXL3EdHnCWitriasfbbsdseJbh5jyWo67rWFWiDdlmgJmuRq4GiIqdg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=efF6LwIw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="efF6LwIw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C086C19421; Wed, 8 Apr 2026 18:31:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775673070; bh=rt/pYLBNJigFbQ0cPdeEp+KKg/f0N2ghn6uRtmuwRnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=efF6LwIwQaaZ3JmdrvIGBSD4ii2NHB1sJhjNQDaIP41RdFB7bbJrxCwYoV6JadfcQ qxxerh/HNTHwgC4WXzR9oIb6/plo0PvGdTeH0SVjfhDXPmmsM8RL6u4oO+r+LtBgZy fuWhe8zkAheg1HT7hkj2bouGMWGL6CYpg5WC5AwM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shay Drory , Mark Bloch , Tariq Toukan , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.18 090/277] net/mlx5: lag: Check for LAG device before creating debugfs Date: Wed, 8 Apr 2026 20:01:15 +0200 Message-ID: <20260408175937.235367723@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175933.836769063@linuxfoundation.org> References: <20260408175933.836769063@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shay Drory [ Upstream commit bf16bca6653679d8a514d6c1c5a2c67065033f14 ] __mlx5_lag_dev_add_mdev() may return 0 (success) even when an error occurs that is handled gracefully. Consequently, the initialization flow proceeds to call mlx5_ldev_add_debugfs() even when there is no valid LAG context. mlx5_ldev_add_debugfs() blindly created the debugfs directory and attributes. This exposed interfaces (like the members file) that rely on a valid ldev pointer, leading to potential NULL pointer dereferences if accessed when ldev is NULL. Add a check to verify that mlx5_lag_dev(dev) returns a valid pointer before attempting to create the debugfs entries. Fixes: 7f46a0b7327a ("net/mlx5: Lag, add debugfs to query hardware lag state") Signed-off-by: Shay Drory Reviewed-by: Mark Bloch Signed-off-by: Tariq Toukan Link: https://patch.msgid.link/20260330194015.53585-2-tariqt@nvidia.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c index 62b6faa4276aa..b8d5f6a44d26a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c @@ -160,8 +160,11 @@ DEFINE_SHOW_ATTRIBUTE(members); void mlx5_ldev_add_debugfs(struct mlx5_core_dev *dev) { + struct mlx5_lag *ldev = mlx5_lag_dev(dev); struct dentry *dbg; + if (!ldev) + return; dbg = debugfs_create_dir("lag", mlx5_debugfs_get_dev_root(dev)); dev->priv.dbg.lag_debugfs = dbg; -- 2.53.0