Skip to content

Commit 41077c9

Browse files
ecree-solarflaredavem330
authored andcommitted
sfc: fix ef100 design-param checking
The handling of the RXQ/TXQ size granularity design-params had two problems: it had a 64-bit divide that didn't build on 32-bit platforms, and it could divide by zero if the NIC supplied 0 as the value of the design-param. Fix both by checking for 0 and for a granularity bigger than our min-size; if the granularity <= EFX_MIN_DMAQ_SIZE then it fits in 32 bits, so we can cast it to u32 for the divide. Reported-by: kernel test robot <[email protected]> Signed-off-by: Edward Cree <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 633f5b6 commit 41077c9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/ethernet/sfc/ef100_nic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,8 @@ static int ef100_process_design_param(struct efx_nic *efx,
979979
* EFX_MIN_DMAQ_SIZE is divisible by GRANULARITY.
980980
* This is very unlikely to fail.
981981
*/
982-
if (EFX_MIN_DMAQ_SIZE % reader->value) {
982+
if (!reader->value || reader->value > EFX_MIN_DMAQ_SIZE ||
983+
EFX_MIN_DMAQ_SIZE % (u32)reader->value) {
983984
netif_err(efx, probe, efx->net_dev,
984985
"%s size granularity is %llu, can't guarantee safety\n",
985986
reader->type == ESE_EF100_DP_GZ_RXQ_SIZE_GRANULARITY ? "RXQ" : "TXQ",

0 commit comments

Comments
 (0)