For some cases when reading from device are incorrect or image is
incorrect, this part of code causes crash due to division by zero.
Fixes:
8db9e2a1b232 ("i40e: base driver")
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
/* partition id is 1-based, and functions are evenly spread
* across the ports as partitions
*/
- hw->partition_id = (hw->pf_id / hw->num_ports) + 1;
- hw->num_partitions = num_functions / hw->num_ports;
+ if (hw->num_ports != 0) {
+ hw->partition_id = (hw->pf_id / hw->num_ports) + 1;
+ hw->num_partitions = num_functions / hw->num_ports;
+ }
/* additional HW specific goodies that might
* someday be HW version specific