Skip to contentSkip to conversation

net/ice: add check for null-pointer dereference

PATCH In review Bruce Richardson 2 participants 3 messages Nov 14, 2024 – Nov 19, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ice: add check for null-pointer dereference

Although it should never occur that the teid (scheduler node id) value for a txq is incorrect, put in a check for null following the scheduler node lookup in ice_tm_setup_txq_node. This provides some additional safety and should eliminate a coverity issue too.

Coverity issue: 448957

Fixes 715d449a965b ("net/ice: enhance Tx scheduler hierarchy support")
---
 drivers/net/ice/ice_tm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ice/ice_tm.c +4 -0
index 18ac324a61..ff3a6cd77f 100644
@@ -679,6 +679,10 @@ ice_tm_setup_txq_node(struct ice_pf *pf, struct ice_hw *hw, uint16_t qid, uint32
 	struct ice_sched_node *hw_node = ice_sched_find_node_by_teid(hw->port_info->root, teid);
 	struct ice_tm_node *sw_node = find_node(pf->tm_conf.root, qid);
 
+	/* bad node teid passed */
+	if (hw_node == NULL)
+		return -ENOENT;
+
 	/* not configured in hierarchy */
 	if (sw_node == NULL)
 		return 0;
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 21 lines

Although it should never occur that the teid (scheduler node id) value for a txq is incorrect, put in a check for null following the scheduler node lookup in ice_tm_setup_txq_node. This provides some additional safety and should eliminate a coverity issue too.

Coverity issue: 448957

Fixes 715d449a965b ("net/ice: enhance Tx scheduler hierarchy support")
---
 drivers/net/ice/ice_tm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ice/ice_tm.c +0 -0
index 18ac324a61..ff3a6cd77f 100644
@@ -679,6 +679,10 @@ ice_tm_setup_txq_node(struct ice_pf *pf, struct

ice_hw *hw, uint16_t qid, uint32
struct ice_sched_node *hw_node = ice_sched_find_node_by_teid(hw-

Quoted 1 line

port_info->root, teid);

drivers/net/ice/ice_tm.c ice_tm_setup_txq_node(struct ice_pf *pf, struct ice_hw *hw, uint16_t qid, uint32 · line 688

Quoted 9 lines
drivers/net/ice/ice_tm.c +4 -0
 	struct ice_tm_node *sw_node = find_node(pf->tm_conf.root, qid);
 
+	/* bad node teid passed */
+	if (hw_node == NULL)
+		return -ENOENT;
+
 	/* not configured in hierarchy */
 	if (sw_node == NULL)
 		return 0;

LGTM.

Quoted 2 lines

--
2.43.0

author Applied
#2 lore raw
Quoted 33 lines · Ian
Quoted 21 lines

Although it should never occur that the teid (scheduler node id) value for a txq is incorrect, put in a check for null following the scheduler node lookup in ice_tm_setup_txq_node. This provides some additional safety and should eliminate a coverity issue too.

Coverity issue: 448957

Fixes 715d449a965b ("net/ice: enhance Tx scheduler hierarchy support")
---
 drivers/net/ice/ice_tm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ice/ice_tm.c +0 -0
index 18ac324a61..ff3a6cd77f 100644
@@ -679,6 +679,10 @@ ice_tm_setup_txq_node(struct ice_pf *pf, struct

ice_hw *hw, uint16_t qid, uint32
struct ice_sched_node *hw_node = ice_sched_find_node_by_teid(hw-

Quoted 1 line

port_info->root, teid);

drivers/net/ice/ice_tm.c ice_tm_setup_txq_node(struct ice_pf *pf, struct ice_hw *hw, uint16_t qid, uint32 · line 688

Quoted 9 lines
drivers/net/ice/ice_tm.c +4 -0
 	struct ice_tm_node *sw_node = find_node(pf->tm_conf.root, qid);
 
+	/* bad node teid passed */
+	if (hw_node == NULL)
+		return -ENOENT;
+
 	/* not configured in hierarchy */
 	if (sw_node == NULL)
 		return 0;

LGTM.

Quoted 2 lines

Applied to dpdk-next-net-intel.

/Bruce