Skip to contentSkip to conversation

net/iavf: fix core dump when the link is unstable

PATCH In review Kaiwen Deng 2 participants 3 messages Aug 6, 2024 – Aug 22, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/iavf: fix core dump when the link is unstable

Physical link instability may cause a core dump. Unstable physical links can result in a large number of link change events.Link change events captured by vf before vf resources are allocated will result in a core dump.

This commit will check if vf_res is invalid before calling it.

Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without interrupt")
---
 drivers/net/iavf/iavf_vchnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/iavf/iavf_vchnl.c +1 -1
index 6d5969f084..b85debd40d 100644
@@ -255,7 +255,7 @@ iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len,
 		case VIRTCHNL_EVENT_LINK_CHANGE:
 			vf->link_up =
 				vpe->event_data.link_event.link_status;
-			if (vf->vf_res->vf_cap_flags &
+			if (vf->vf_res != NULL && vf->vf_res->vf_cap_flags &
 				VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {
 				vf->link_speed =
 				    vpe->event_data.link_event_adv.link_speed;
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Kaiwen Deng

Physical link instability may cause a core dump. Unstable physical links can result in a large number of link change events.Link change events captured by vf before vf resources are allocated will result in a core dump.

This commit will check if vf_res is invalid before calling it.

Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without interrupt")
Quoted 9 lines
---
 drivers/net/iavf/iavf_vchnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/iavf/iavf_vchnl.c +0 -0
index 6d5969f084..b85debd40d 100644

drivers/net/iavf/iavf_vchnl.c iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len, · line 259

Quoted 6 lines
drivers/net/iavf/iavf_vchnl.c +1 -1
@@ -255,7 +255,7 @@ iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len,
 		case VIRTCHNL_EVENT_LINK_CHANGE:
 			vf->link_up =
 				vpe->event_data.link_event.link_status;
-			if (vf->vf_res->vf_cap_flags &
+			if (vf->vf_res != NULL && vf->vf_res->vf_cap_flags &
 				VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {

Since we are adjusting the conditional, we might as well fix the indentation of it while we are at it. We can use up to 100 columns in DPDK code, so there is no need to split the flags comparison across two lines. Also the line continuation should not use a single tab indent - that makes it look part of the body of the "if" statement, not part of the conditional itself.
Will fix this on apply.

Thanks.

#2 lore raw
Quoted 30 lines · Bruce Richardson
Quoted 11 lines · Kaiwen Deng

Physical link instability may cause a core dump. Unstable physical links can result in a large number of link change events.Link change events captured by vf before vf resources are allocated will result in a core dump.

This commit will check if vf_res is invalid before calling it.

Fixes 5e03e316c753 ("net/iavf: handle virtchnl event message without interrupt")
Quoted 9 lines
---
 drivers/net/iavf/iavf_vchnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/iavf/iavf_vchnl.c +0 -0
index 6d5969f084..b85debd40d 100644

drivers/net/iavf/iavf_vchnl.c iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len, · line 259

Quoted 6 lines
drivers/net/iavf/iavf_vchnl.c +1 -1
@@ -255,7 +255,7 @@ iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len,
 		case VIRTCHNL_EVENT_LINK_CHANGE:
 			vf->link_up =
 				vpe->event_data.link_event.link_status;
-			if (vf->vf_res->vf_cap_flags &
+			if (vf->vf_res != NULL && vf->vf_res->vf_cap_flags &
 				VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {
Quoted 8 lines

Since we are adjusting the conditional, we might as well fix the indentation of it while we are at it. We can use up to 100 columns in DPDK code, so there is no need to split the flags comparison across two lines. Also the line continuation should not use a single tab indent - that makes it look part of the body of the "if" statement, not part of the conditional itself.
Will fix this on apply.

Patch applied to dpdk-next-net-intel

/Bruce