Skip to content

Commit c50e747

Browse files
Dan Carpenterkuba-moo
authored andcommitted
dpaa2-switch: Fix error checking in dpaa2_switch_seed_bp()
The dpaa2_switch_add_bufs() function returns the number of bufs that it was able to add. It returns BUFS_PER_CMD (7) for complete success or a smaller number if there are not enough pages available. However, the error checking is looking at the total number of bufs instead of the number which were added on this iteration. Thus the error checking only works correctly for the first iteration through the loop and subsequent iterations are always counted as a success. Fix this by checking only the bufs added in the current iteration. Fixes: 0b1b713 ("staging: dpaa2-switch: handle Rx path on control interface") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Ioana Ciornei <[email protected]> Tested-by: Ioana Ciornei <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7565c39 commit c50e747

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2638,13 +2638,14 @@ static int dpaa2_switch_refill_bp(struct ethsw_core *ethsw)
26382638

26392639
static int dpaa2_switch_seed_bp(struct ethsw_core *ethsw)
26402640
{
2641-
int *count, i;
2641+
int *count, ret, i;
26422642

26432643
for (i = 0; i < DPAA2_ETHSW_NUM_BUFS; i += BUFS_PER_CMD) {
2644+
ret = dpaa2_switch_add_bufs(ethsw, ethsw->bpid);
26442645
count = &ethsw->buf_count;
2645-
*count += dpaa2_switch_add_bufs(ethsw, ethsw->bpid);
2646+
*count += ret;
26462647

2647-
if (unlikely(*count < BUFS_PER_CMD))
2648+
if (unlikely(ret < BUFS_PER_CMD))
26482649
return -ENOMEM;
26492650
}
26502651

0 commit comments

Comments
 (0)