mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Divide-by-zero error in qed_hw_get_nvm_info()
@ 2025-03-03  6:40 Kyungwook Boo
  0 siblings, 0 replies; only message in thread
From: Kyungwook Boo @ 2025-03-03  6:40 UTC (permalink / raw)
  To: Manish Chopra; +Cc: netdev, linux-kernel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-03-03  6:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-03  6:40 Divide-by-zero error in qed_hw_get_nvm_info() Kyungwook Boo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®