Skip to content

Commit e76ebc2

Browse files
cloftusbruce-richardson
authored andcommitted
net/ice: fix shaper profile reference count tracking
Currently, when a TM node is added with a shaper profile assigned, the profile's reference count is not incremented. Equally, when a node is deleted, the count is not decremented. As a result, the guard that blocks deletion of an in-use profile never triggers, allowing the profile to be freed while nodes still hold a pointer to it. Fix by maintaining the reference count correctly when nodes take or release a shaper profile, so that deletion of an in-use profile is properly rejected. Fixes: 8c481c3 ("net/ice: support queue and queue group bandwidth limit") Cc: stable@dpdk.org Signed-off-by: Ciara Loftus <ciara.loftus@intel.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
1 parent ef9dc56 commit e76ebc2

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/net/intel/ice/ice_tm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
456456
tm_node->parent = NULL;
457457
tm_node->reference_count = 0;
458458
tm_node->shaper_profile = shaper_profile;
459+
if (shaper_profile != NULL)
460+
shaper_profile->reference_count++;
459461
tm_node->children = RTE_PTR_ADD(tm_node, sizeof(struct ice_tm_node));
460462
tm_node->params = *params;
461463
pf->tm_conf.root = tm_node;
@@ -518,6 +520,8 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
518520
tm_node->parent = parent_node;
519521
tm_node->level = level_id;
520522
tm_node->shaper_profile = shaper_profile;
523+
if (shaper_profile != NULL)
524+
shaper_profile->reference_count++;
521525
tm_node->children = RTE_PTR_ADD(tm_node, sizeof(struct ice_tm_node));
522526
tm_node->parent->children[tm_node->parent->reference_count++] = tm_node;
523527
tm_node->params = *params;
@@ -568,6 +572,8 @@ ice_tm_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
568572

569573
/* root node */
570574
if (tm_node->level == 0) {
575+
if (tm_node->shaper_profile != NULL)
576+
tm_node->shaper_profile->reference_count--;
571577
rte_free(tm_node);
572578
pf->tm_conf.root = NULL;
573579
return 0;
@@ -582,6 +588,8 @@ ice_tm_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
582588
tm_node->parent->children[j] = tm_node->parent->children[j + 1];
583589

584590
tm_node->parent->reference_count--;
591+
if (tm_node->shaper_profile != NULL)
592+
tm_node->shaper_profile->reference_count--;
585593
rte_free(tm_node);
586594

587595
return 0;

0 commit comments

Comments
 (0)