Divide-by-zero error in qed_hw_get_nvm_info()

From: Kyungwook Boo <hidden>
Date: 2025-03-03 06:41:00
Also in: lkml

Hello,

It seems that qed_hw_info_port_num() reads the value of num_ports from MMIO
and then qed_hw_get_nvm_info() performs a division opertation
using this value, which could lead to a divide-by-zero error.

The following is a call stack example:

 qed_probe
   ├── qed_hw_prepare
   │     ├── qed_hw_prepare_single
   │     │     ├── qed_get_hw_info
   │     │     │     ├── qed_hw_info_port_num
   │     │     │     │     ├── qed_rd (MMIO read: num_ports)
   │     │     │     ├── qed_hw_get_nvm_info
   │     │     │     │     ├── MFW_PORT (uses num_ports in modulo)

In qed_hw_info_port_num(), cdev->num_ports is read from MMIO:

cdev->num_ports = (u8)qed_rd(p_hwfn, p_ptt, addr);


This value is then used for modulo operation in qed_hw_get_nvm_info():

port_cfg_addr = MCP_REG_SCRATCH + nvm_cfg1_offset +
	offsetof(struct nvm_cfg1, port[MFW_PORT(p_hwfn)]);

// #define MFW_PORT(_p_hwfn)       ((_p_hwfn)->abs_pf_id %	\
//		  qed_device_num_ports((_p_hwfn)->cdev))


Could you check this?

Best regards,
Kyungwook Boo
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help