Skip to content

Commit a1c7c49

Browse files
shayshyiSaeed Mahameed
authored andcommitted
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: 1958fc2 ("net/mlx5: SF, Add auxiliary device driver") Signed-off-by: Shay Drory <[email protected]> Reviewed-by: Parav Pandit <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent b6dfff2 commit a1c7c49

File tree

1 file changed

+1
-4
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/sf/dev

1 file changed

+1
-4
lines changed

drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ bool mlx5_sf_dev_allocated(const struct mlx5_core_dev *dev)
3030
{
3131
struct mlx5_sf_dev_table *table = dev->priv.sf_dev_table;
3232

33-
if (!mlx5_sf_dev_supported(dev))
34-
return false;
35-
36-
return !xa_empty(&table->devices);
33+
return table && !xa_empty(&table->devices);
3734
}
3835

3936
static ssize_t sfnum_show(struct device *dev, struct device_attribute *attr, char *buf)

0 commit comments

Comments
 (0)