Skip to content

Commit

Permalink
Merge branch 'rswitch-fixes'
Browse files Browse the repository at this point in the history
Yoshihiro Shimoda says:

====================
net: rswitch: Fix issues in rswitch_start_xmit()

This patch series is based on the latest net.git / main branch.

Changes from v2:
https://lore.kernel.org/all/[email protected]/
- Keep reverse christmas tree of local variable declarations in patch 1/3.

Changes from v1:
https://lore.kernel.org/all/[email protected]/
- Separate a patch because fixing 2 issues.
- Add fixing wrong type of return value.
- Use goto for improving code readability.
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Nov 24, 2023
2 parents d3fa86b + 782486a commit c9213dd
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions drivers/net/ethernet/renesas/rswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1504,8 +1504,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
{
struct rswitch_device *rdev = netdev_priv(ndev);
struct rswitch_gwca_queue *gq = rdev->tx_queue;
netdev_tx_t ret = NETDEV_TX_OK;
struct rswitch_ext_desc *desc;
int ret = NETDEV_TX_OK;
dma_addr_t dma_addr;

if (rswitch_get_num_cur_queues(gq) >= gq->ring_size - 1) {
Expand All @@ -1517,10 +1517,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
return ret;

dma_addr = dma_map_single(ndev->dev.parent, skb->data, skb->len, DMA_TO_DEVICE);
if (dma_mapping_error(ndev->dev.parent, dma_addr)) {
dev_kfree_skb_any(skb);
return ret;
}
if (dma_mapping_error(ndev->dev.parent, dma_addr))
goto err_kfree;

gq->skbs[gq->cur] = skb;
desc = &gq->tx_ring[gq->cur];
Expand All @@ -1533,10 +1531,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
struct rswitch_gwca_ts_info *ts_info;

ts_info = kzalloc(sizeof(*ts_info), GFP_ATOMIC);
if (!ts_info) {
dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE);
return -ENOMEM;
}
if (!ts_info)
goto err_unmap;

skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
rdev->ts_tag++;
Expand All @@ -1558,6 +1554,14 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
gq->cur = rswitch_next_queue_index(gq, true, 1);
rswitch_modify(rdev->addr, GWTRC(gq->index), 0, BIT(gq->index % 32));

return ret;

err_unmap:
dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE);

err_kfree:
dev_kfree_skb_any(skb);

return ret;
}

Expand Down

0 comments on commit c9213dd

Please sign in to comment.