net/mlx5: Fix access to sf_dev_table on allocation failure
authorShay Drory <shayd@nvidia.com>
Thu, 30 Dec 2021 06:54:08 +0000 (08:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 10:03:57 +0000 (11:03 +0100)
commitfbe5f19824baacaeb3aff38a4841d70e0d0da1bc
tree5c3129ada1a239b35caeb4eda6e37274668af3fe
parent7c1f9797e1b55cb14e9e9bcb817b39d06e021fc8
net/mlx5: Fix access to sf_dev_table on allocation failure

[ Upstream commit a1c7c49c2091926962f8c1c866d386febffec5d8 ]

Even when SF devices are supported, the SF device table allocation
can still fail.
In such case mlx5_sf_dev_supported still reports true, but SF device
table is invalid. This can result in NULL table access.

Hence, fix it by adding NULL table check.

Fixes: 1958fc2f0712 ("net/mlx5: SF, Add auxiliary device driver")
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c