* [PATCH net v2 1/3] net: rswitch: Fix type of ret in rswitch_start_xmit()
2023-11-22 1:25 [PATCH net v2 0/3] net: rswitch: Fix issues in rswitch_start_xmit() Yoshihiro Shimoda
@ 2023-11-22 1:25 ` Yoshihiro Shimoda
2023-11-22 3:10 ` Andrew Lunn
2023-11-22 1:25 ` [PATCH net v2 2/3] net: rswitch: Fix return value " Yoshihiro Shimoda
2023-11-22 1:25 ` [PATCH net v2 3/3] net: rswitch: Fix missing dev_kfree_skb_any() in error path Yoshihiro Shimoda
2 siblings, 1 reply; 6+ messages in thread
From: Yoshihiro Shimoda @ 2023-11-22 1:25 UTC (permalink / raw)
To: s.shtylyov, davem, edumazet, kuba, pabeni
Cc: netdev, linux-renesas-soc, Yoshihiro Shimoda
The type of ret in rswitch_start_xmit() should be netdev_tx_t. So,
fix it.
Fixes: 3590918b5d07 ("net: ethernet: renesas: Add support for "Ethernet Switch"")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
drivers/net/ethernet/renesas/rswitch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index 43a7795d6591..abaaa1112588 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1505,7 +1505,7 @@ 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;
struct rswitch_ext_desc *desc;
- int ret = NETDEV_TX_OK;
+ netdev_tx_t ret = NETDEV_TX_OK;
dma_addr_t dma_addr;
if (rswitch_get_num_cur_queues(gq) >= gq->ring_size - 1) {
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net v2 2/3] net: rswitch: Fix return value in rswitch_start_xmit()
2023-11-22 1:25 [PATCH net v2 0/3] net: rswitch: Fix issues in rswitch_start_xmit() Yoshihiro Shimoda
2023-11-22 1:25 ` [PATCH net v2 1/3] net: rswitch: Fix type of ret " Yoshihiro Shimoda
@ 2023-11-22 1:25 ` Yoshihiro Shimoda
2023-11-22 1:25 ` [PATCH net v2 3/3] net: rswitch: Fix missing dev_kfree_skb_any() in error path Yoshihiro Shimoda
2 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2023-11-22 1:25 UTC (permalink / raw)
To: s.shtylyov, davem, edumazet, kuba, pabeni
Cc: netdev, linux-renesas-soc, Yoshihiro Shimoda
This .ndo_start_xmit() function should return netdev_tx_t value,
not -ENOMEM. So, fix it.
Fixes: 33f5d733b589 ("net: renesas: rswitch: Improve TX timestamp accuracy")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
drivers/net/ethernet/renesas/rswitch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index abaaa1112588..61c15e7a2a2c 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1535,7 +1535,7 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
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;
+ return ret;
}
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net v2 3/3] net: rswitch: Fix missing dev_kfree_skb_any() in error path
2023-11-22 1:25 [PATCH net v2 0/3] net: rswitch: Fix issues in rswitch_start_xmit() Yoshihiro Shimoda
2023-11-22 1:25 ` [PATCH net v2 1/3] net: rswitch: Fix type of ret " Yoshihiro Shimoda
2023-11-22 1:25 ` [PATCH net v2 2/3] net: rswitch: Fix return value " Yoshihiro Shimoda
@ 2023-11-22 1:25 ` Yoshihiro Shimoda
2 siblings, 0 replies; 6+ messages in thread
From: Yoshihiro Shimoda @ 2023-11-22 1:25 UTC (permalink / raw)
To: s.shtylyov, davem, edumazet, kuba, pabeni
Cc: netdev, linux-renesas-soc, Yoshihiro Shimoda
Before returning the rswitch_start_xmit() in the error path,
dev_kfree_skb_any() should be called. So, fix it.
Fixes: 33f5d733b589 ("net: renesas: rswitch: Improve TX timestamp accuracy")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
drivers/net/ethernet/renesas/rswitch.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index 61c15e7a2a2c..ab5daf657fdd 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -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];
@@ -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 ret;
- }
+ if (!ts_info)
+ goto err_unmap;
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
rdev->ts_tag++;
@@ -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;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread