Skip to content

Commit e05bb97

Browse files
shimodaydavem330
authored andcommitted
net: renesas: rswitch: Fix the output value of quote from rswitch_rx()
If the RX descriptor doesn't have any data, the output value of quote from rswitch_rx() will be increased unexpectedily. So, fix it. Reported-by: Volodymyr Babchuk <[email protected]> Fixes: 3590918 ("net: ethernet: renesas: Add support for "Ethernet Switch"") Signed-off-by: Yoshihiro Shimoda <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 90de546 commit e05bb97

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/net/ethernet/renesas/rswitch.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,13 +702,14 @@ static bool rswitch_rx(struct net_device *ndev, int *quota)
702702
u16 pkt_len;
703703
u32 get_ts;
704704

705+
if (*quota <= 0)
706+
return true;
707+
705708
boguscnt = min_t(int, gq->ring_size, *quota);
706709
limit = boguscnt;
707710

708711
desc = &gq->rx_ring[gq->cur];
709712
while ((desc->desc.die_dt & DT_MASK) != DT_FEMPTY) {
710-
if (--boguscnt < 0)
711-
break;
712713
dma_rmb();
713714
pkt_len = le16_to_cpu(desc->desc.info_ds) & RX_DS;
714715
skb = gq->skbs[gq->cur];
@@ -734,6 +735,9 @@ static bool rswitch_rx(struct net_device *ndev, int *quota)
734735

735736
gq->cur = rswitch_next_queue_index(gq, true, 1);
736737
desc = &gq->rx_ring[gq->cur];
738+
739+
if (--boguscnt <= 0)
740+
break;
737741
}
738742

739743
num = rswitch_get_num_cur_queues(gq);
@@ -745,7 +749,7 @@ static bool rswitch_rx(struct net_device *ndev, int *quota)
745749
goto err;
746750
gq->dirty = rswitch_next_queue_index(gq, false, num);
747751

748-
*quota -= limit - (++boguscnt);
752+
*quota -= limit - boguscnt;
749753

750754
return boguscnt <= 0;
751755

0 commit comments

Comments
 (0)