Skip to content

Commit 999b315

Browse files
MichalKosiarzJeff Kirsher
authored andcommitted
i40e: Fix for division by zero
For some cases when reading from device are incorrect or image is incorrect, this part of code causes crash due to division by zero. Change-ID: I8961029a7a87b0a479995823ef8fcbf6471405e1 Signed-off-by: Michal Kosiarz <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 13fd3f9 commit 999b315

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/ethernet/intel/i40e/i40e_common.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3313,8 +3313,10 @@ static void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
33133313
/* partition id is 1-based, and functions are evenly spread
33143314
* across the ports as partitions
33153315
*/
3316-
hw->partition_id = (hw->pf_id / hw->num_ports) + 1;
3317-
hw->num_partitions = num_functions / hw->num_ports;
3316+
if (hw->num_ports != 0) {
3317+
hw->partition_id = (hw->pf_id / hw->num_ports) + 1;
3318+
hw->num_partitions = num_functions / hw->num_ports;
3319+
}
33183320

33193321
/* additional HW specific goodies that might
33203322
* someday be HW version specific

0 commit comments

Comments
 (0)