Skip to content

Commit 83a7f27

Browse files
Hariprasad Kelamgregkh
authored andcommitted
octeontx2-af: Add validation for lmac type
[ Upstream commit cb5edce ] Upon physical link change, firmware reports to the kernel about the change along with the details like speed, lmac_type_id, etc. Kernel derives lmac_type based on lmac_type_id received from firmware. In a few scenarios, firmware returns an invalid lmac_type_id, which is resulting in below kernel panic. This patch adds the missing validation of the lmac_type_id field. Internal error: Oops: 96000005 [Freescale#1] PREEMPT SMP [ 35.321595] Modules linked in: [ 35.328982] CPU: 0 PID: 31 Comm: kworker/0:1 Not tainted 5.4.210-g2e3169d8e1bc-dirty Freescale#17 [ 35.337014] Hardware name: Marvell CN103XX board (DT) [ 35.344297] Workqueue: events work_for_cpu_fn [ 35.352730] pstate: 40400089 (nZcv daIf +PAN -UAO) [ 35.360267] pc : strncpy+0x10/0x30 [ 35.366595] lr : cgx_link_change_handler+0x90/0x180 Fixes: 61071a8 ("octeontx2-af: Forward CGX link notifications to PFs") Signed-off-by: Hariprasad Kelam <[email protected]> Signed-off-by: Sunil Kovvuri Goutham <[email protected]> Signed-off-by: Sai Krishna <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 3236221 commit 83a7f27

File tree

1 file changed

+8
-0
lines changed
  • drivers/net/ethernet/marvell/octeontx2/af

1 file changed

+8
-0
lines changed

drivers/net/ethernet/marvell/octeontx2/af/cgx.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,14 @@ static inline void link_status_user_format(u64 lstat,
12251225
linfo->an = FIELD_GET(RESP_LINKSTAT_AN, lstat);
12261226
linfo->fec = FIELD_GET(RESP_LINKSTAT_FEC, lstat);
12271227
linfo->lmac_type_id = cgx_get_lmac_type(cgx, lmac_id);
1228+
1229+
if (linfo->lmac_type_id >= LMAC_MODE_MAX) {
1230+
dev_err(&cgx->pdev->dev, "Unknown lmac_type_id %d reported by firmware on cgx port%d:%d",
1231+
linfo->lmac_type_id, cgx->cgx_id, lmac_id);
1232+
strncpy(linfo->lmac_type, "Unknown", LMACTYPE_STR_LEN - 1);
1233+
return;
1234+
}
1235+
12281236
lmac_string = cgx_lmactype_string[linfo->lmac_type_id];
12291237
strncpy(linfo->lmac_type, lmac_string, LMACTYPE_STR_LEN - 1);
12301238
}

0 commit comments

Comments
 (0)