@@ -178,9 +178,14 @@ odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param)
for (i = 0; i < ODP_COS_MAX_ENTRY; i++) {
LOCK(&cos_tbl->cos_entry[i].s.lock);
if (0 == cos_tbl->cos_entry[i].s.valid) {
- strncpy(cos_tbl->cos_entry[i].s.name, name,
- ODP_COS_NAME_LEN - 1);
- cos_tbl->cos_entry[i].s.name[ODP_COS_NAME_LEN - 1] = 0;
+ char *cos_name = cos_tbl->cos_entry[i].s.name;
+
+ if (name == NULL) {
+ cos_name[0] = 0;
+ } else {
+ strncpy(cos_name, name, ODP_COS_NAME_LEN - 1);
+ cos_name[ODP_COS_NAME_LEN - 1] = 0;
+ }
for (j = 0; j < ODP_PMR_PER_COS_MAX; j++) {
cos_tbl->cos_entry[i].s.pmr[j] = NULL;
cos_tbl->cos_entry[i].s.linked_cos[j] = NULL;
@@ -16,7 +16,6 @@ void classification_test_create_cos(void)
odp_cls_cos_param_t cls_param;
odp_pool_t pool;
odp_queue_t queue;
- char cosname[ODP_COS_NAME_LEN];
pool = pool_create("cls_basic_pool");
CU_ASSERT_FATAL(pool != ODP_POOL_INVALID);
@@ -24,13 +23,12 @@ void classification_test_create_cos(void)
queue = queue_create("cls_basic_queue", true);
CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID);
- sprintf(cosname, "ClassOfService");
odp_cls_cos_param_init(&cls_param);
cls_param.pool = pool;
cls_param.queue = queue;
cls_param.drop_policy = ODP_COS_DROP_POOL;
- cos = odp_cls_cos_create(cosname, &cls_param);
+ cos = odp_cls_cos_create(NULL, &cls_param);
CU_ASSERT(odp_cos_to_u64(cos) != odp_cos_to_u64(ODP_COS_INVALID));
odp_cos_destroy(cos);
odp_pool_destroy(pool);
Previously trying to create a class-of-service with no name (=NULL) caused a segfault. Fix this and test it in the validation suite. Signed-off-by: Matias Elo <matias.elo@nokia.com> --- platform/linux-generic/odp_classification.c | 11 ++++++++--- .../validation/api/classification/odp_classification_basic.c | 4 +--- 2 files changed, 9 insertions(+), 6 deletions(-) -- 2.7.4