Skip to content

Commit

Permalink
distributor: fix check of workers number
Browse files Browse the repository at this point in the history
[ upstream commit acc6e55 ]

No of workers should never exceed RTE_MAX_LCORE.
RTE_DIST_ALG_SINGLE also require no of workers check.

Fixes: 775003a ("distributor: add new burst-capable library")

Signed-off-by: Harman Kalra <hkalra@marvell.com>
Acked-by: David Hunt <david.hunt@intel.com>
  • Loading branch information
Harman Kalra authored and kevintraynor committed Aug 26, 2019
1 parent 8ba090c commit 6ba96c6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/librte_distributor/rte_distributor.c
Expand Up @@ -595,6 +595,12 @@ rte_distributor_create_v1705(const char *name,
RTE_BUILD_BUG_ON((sizeof(*d) & RTE_CACHE_LINE_MASK) != 0);
RTE_BUILD_BUG_ON((RTE_DISTRIB_MAX_WORKERS & 7) != 0);

if (name == NULL || num_workers >=
(unsigned int)RTE_MIN(RTE_DISTRIB_MAX_WORKERS, RTE_MAX_LCORE)) {
rte_errno = EINVAL;
return NULL;
}

if (alg_type == RTE_DIST_ALG_SINGLE) {
d = malloc(sizeof(struct rte_distributor));
if (d == NULL) {
Expand All @@ -612,11 +618,6 @@ rte_distributor_create_v1705(const char *name,
return d;
}

if (name == NULL || num_workers >= RTE_DISTRIB_MAX_WORKERS) {
rte_errno = EINVAL;
return NULL;
}

snprintf(mz_name, sizeof(mz_name), RTE_DISTRIB_PREFIX"%s", name);
mz = rte_memzone_reserve(mz_name, sizeof(*d), socket_id, NO_FLAGS);
if (mz == NULL) {
Expand Down

0 comments on commit 6ba96c6

Please sign in to comment.