Commit e05bb97d authored by Yoshihiro Shimoda's avatar Yoshihiro Shimoda Committed by David S. Miller

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: default avatarVolodymyr Babchuk <volodymyr_babchuk@epam.com>
Fixes: 3590918b ("net: ethernet: renesas: Add support for "Ethernet Switch"")
Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 90de546d
...@@ -702,13 +702,14 @@ static bool rswitch_rx(struct net_device *ndev, int *quota) ...@@ -702,13 +702,14 @@ static bool rswitch_rx(struct net_device *ndev, int *quota)
u16 pkt_len; u16 pkt_len;
u32 get_ts; u32 get_ts;
if (*quota <= 0)
return true;
boguscnt = min_t(int, gq->ring_size, *quota); boguscnt = min_t(int, gq->ring_size, *quota);
limit = boguscnt; limit = boguscnt;
desc = &gq->rx_ring[gq->cur]; desc = &gq->rx_ring[gq->cur];
while ((desc->desc.die_dt & DT_MASK) != DT_FEMPTY) { while ((desc->desc.die_dt & DT_MASK) != DT_FEMPTY) {
if (--boguscnt < 0)
break;
dma_rmb(); dma_rmb();
pkt_len = le16_to_cpu(desc->desc.info_ds) & RX_DS; pkt_len = le16_to_cpu(desc->desc.info_ds) & RX_DS;
skb = gq->skbs[gq->cur]; skb = gq->skbs[gq->cur];
...@@ -734,6 +735,9 @@ static bool rswitch_rx(struct net_device *ndev, int *quota) ...@@ -734,6 +735,9 @@ static bool rswitch_rx(struct net_device *ndev, int *quota)
gq->cur = rswitch_next_queue_index(gq, true, 1); gq->cur = rswitch_next_queue_index(gq, true, 1);
desc = &gq->rx_ring[gq->cur]; desc = &gq->rx_ring[gq->cur];
if (--boguscnt <= 0)
break;
} }
num = rswitch_get_num_cur_queues(gq); num = rswitch_get_num_cur_queues(gq);
...@@ -745,7 +749,7 @@ static bool rswitch_rx(struct net_device *ndev, int *quota) ...@@ -745,7 +749,7 @@ static bool rswitch_rx(struct net_device *ndev, int *quota)
goto err; goto err;
gq->dirty = rswitch_next_queue_index(gq, false, num); gq->dirty = rswitch_next_queue_index(gq, false, num);
*quota -= limit - (++boguscnt); *quota -= limit - boguscnt;
return boguscnt <= 0; return boguscnt <= 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment