net/mlx5: DR, Add check for flex parser ID value
authorYevgeny Kliteynik <kliteyn@nvidia.com>
Wed, 10 Nov 2021 22:22:29 +0000 (00:22 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Fri, 31 Dec 2021 08:17:06 +0000 (00:17 -0800)
Allow only legal values for flex parser ID - values from 0 to 7.
For other values skip the parser, and as a result the matcher creation
will fail for using invalid flex parser ID.

Signed-off-by: Hamdan Igbaria <hamdani@nvidia.com>
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c

index b0649c2877dd631a8a6746a8dd27e065bf644828..17bfd1ec058962902ba4caeac1497158354f5279 100644 (file)
@@ -1704,7 +1704,7 @@ static void dr_ste_v0_set_flex_parser(u32 *misc4_field_id,
        u32 id = *misc4_field_id;
        u8 *parser_ptr;
 
-       if (parser_is_used[id])
+       if (id >= DR_NUM_OF_FLEX_PARSERS || parser_is_used[id])
                return;
 
        parser_is_used[id] = true;
index cb9cf67b0a02fe3fa9423a5fac11c978b009247a..a7772804f8e59fdfe986d07cace4245369ad22b7 100644 (file)
@@ -1833,7 +1833,7 @@ static void dr_ste_v1_set_flex_parser(u32 *misc4_field_id,
        u32 id = *misc4_field_id;
        u8 *parser_ptr;
 
-       if (parser_is_used[id])
+       if (id >= DR_NUM_OF_FLEX_PARSERS || parser_is_used[id])
                return;
 
        parser_is_used[id] = true;