Commit a1c7c49c authored by Shay Drory's avatar Shay Drory Committed by Saeed Mahameed

net/mlx5: Fix access to sf_dev_table on allocation failure

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: 1958fc2f ("net/mlx5: SF, Add auxiliary device driver")
Signed-off-by: default avatarShay Drory <shayd@nvidia.com>
Reviewed-by: default avatarParav Pandit <parav@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent b6dfff21
...@@ -30,10 +30,7 @@ bool mlx5_sf_dev_allocated(const struct mlx5_core_dev *dev) ...@@ -30,10 +30,7 @@ bool mlx5_sf_dev_allocated(const struct mlx5_core_dev *dev)
{ {
struct mlx5_sf_dev_table *table = dev->priv.sf_dev_table; struct mlx5_sf_dev_table *table = dev->priv.sf_dev_table;
if (!mlx5_sf_dev_supported(dev)) return table && !xa_empty(&table->devices);
return false;
return !xa_empty(&table->devices);
} }
static ssize_t sfnum_show(struct device *dev, struct device_attribute *attr, char *buf) static ssize_t sfnum_show(struct device *dev, struct device_attribute *attr, char *buf)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment