net/mlx5: check maximum Verbs port number
authorXueming Li <xuemingl@nvidia.com>
Wed, 21 Jul 2021 14:37:36 +0000 (22:37 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 21 Jul 2021 22:11:14 +0000 (00:11 +0200)
Verbs API doesn't support device port number larger than 255 by design.
Add check and fail probing with proper error log.

Signed-off-by: Xueming Li <xuemingl@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
drivers/net/mlx5/linux/mlx5_os.c

index f041f90..db44169 100644 (file)
@@ -1294,6 +1294,12 @@ err_secondary:
                config->dv_flow_en = 0;
        }
 #endif
+       if (spawn->max_port > UINT8_MAX) {
+               /* Verbs can't support ports larger than 255 by design. */
+               DRV_LOG(ERR, "can't support IB ports > UINT8_MAX");
+               err = EINVAL;
+               goto error;
+       }
        config->ind_table_max_size =
                sh->device_attr.max_rwq_indirection_table_size;
        /*