* [PATCH 2/3 net] net: ti: icssg-prueth: Fix signedness bug in prueth_init_tx_chns()
2023-09-26 14:04 [PATCH 1/3 net] net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns() Dan Carpenter
@ 2023-09-26 14:05 ` Dan Carpenter
2023-09-27 11:29 ` Roger Quadros
2023-09-26 14:06 ` [PATCH 3/3 net] dmaengine: ti: k3-udma-glue: clean up k3_udma_glue_tx_get_irq() return Dan Carpenter
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Dan Carpenter @ 2023-09-26 14:05 UTC (permalink / raw)
To: Roger Quadros
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
MD Danish Anwar, Andrew Lunn, Grygorii Strashko,
Vignesh Raghavendra, netdev, kernel-janitors
The "tx_chn->irq" variable is unsigned so the error checking does not
work correctly.
Fixes: 128d5874c082 ("net: ti: icssg-prueth: Add ICSSG ethernet driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/net/ethernet/ti/icssg/icssg_prueth.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
index 92b13057d4de..89c0c3449d98 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
@@ -316,12 +316,14 @@ static int prueth_init_tx_chns(struct prueth_emac *emac)
goto fail;
}
- tx_chn->irq = k3_udma_glue_tx_get_irq(tx_chn->tx_chn);
- if (tx_chn->irq <= 0) {
- ret = -EINVAL;
+ ret = k3_udma_glue_tx_get_irq(tx_chn->tx_chn);
+ if (ret <= 0) {
+ if (!ret)
+ ret = -EINVAL;
netdev_err(ndev, "failed to get tx irq\n");
goto fail;
}
+ tx_chn->irq = ret;
snprintf(tx_chn->name, sizeof(tx_chn->name), "%s-tx%d",
dev_name(dev), tx_chn->id);
--
2.39.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 2/3 net] net: ti: icssg-prueth: Fix signedness bug in prueth_init_tx_chns()
2023-09-26 14:05 ` [PATCH 2/3 net] net: ti: icssg-prueth: Fix signedness bug in prueth_init_tx_chns() Dan Carpenter
@ 2023-09-27 11:29 ` Roger Quadros
0 siblings, 0 replies; 8+ messages in thread
From: Roger Quadros @ 2023-09-27 11:29 UTC (permalink / raw)
To: Dan Carpenter
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
MD Danish Anwar, Andrew Lunn, Grygorii Strashko,
Vignesh Raghavendra, netdev, kernel-janitors
On 26.9.2023 17.05, Dan Carpenter wrote:
> The "tx_chn->irq" variable is unsigned so the error checking does not
> work correctly.
>
> Fixes: 128d5874c082 ("net: ti: icssg-prueth: Add ICSSG ethernet driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3 net] dmaengine: ti: k3-udma-glue: clean up k3_udma_glue_tx_get_irq() return
2023-09-26 14:04 [PATCH 1/3 net] net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns() Dan Carpenter
2023-09-26 14:05 ` [PATCH 2/3 net] net: ti: icssg-prueth: Fix signedness bug in prueth_init_tx_chns() Dan Carpenter
@ 2023-09-26 14:06 ` Dan Carpenter
2023-09-26 18:46 ` Roger Quadros
2023-09-28 7:50 ` Vinod Koul
2023-09-26 18:44 ` [PATCH 1/3 net] net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns() Roger Quadros
2023-10-04 9:40 ` patchwork-bot+netdevbpf
3 siblings, 2 replies; 8+ messages in thread
From: Dan Carpenter @ 2023-09-26 14:06 UTC (permalink / raw)
To: Peter Ujfalusi
Cc: Vinod Koul, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Siddharth Vadapalli, Roger Quadros,
Grygorii Strashko, MD Danish Anwar, Andrew Lunn,
Vignesh Raghavendra, dmaengine, linux-kernel, netdev,
kernel-janitors
The k3_udma_glue_tx_get_irq() function currently returns negative error
codes on error, zero on error and positive values for success. This
complicates life for the callers who need to propagate the error code.
Also GCC will not warn about unsigned comparisons when you check:
if (unsigned_irq <= 0)
All the callers have been fixed now but let's just make this easy going
forward.
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/dma/ti/k3-udma-glue.c | 3 +++
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 4 ++--
drivers/net/ethernet/ti/icssg/icssg_prueth.c | 4 +---
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c
index 789193ed0386..c278d5facf7d 100644
--- a/drivers/dma/ti/k3-udma-glue.c
+++ b/drivers/dma/ti/k3-udma-glue.c
@@ -558,6 +558,9 @@ int k3_udma_glue_tx_get_irq(struct k3_udma_glue_tx_channel *tx_chn)
tx_chn->virq = k3_ringacc_get_ring_irq_num(tx_chn->ringtxcq);
}
+ if (!tx_chn->virq)
+ return -ENXIO;
+
return tx_chn->virq;
}
EXPORT_SYMBOL_GPL(k3_udma_glue_tx_get_irq);
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 31e84c503e22..24120605502f 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -1747,10 +1747,10 @@ static int am65_cpsw_nuss_init_tx_chns(struct am65_cpsw_common *common)
}
tx_chn->irq = k3_udma_glue_tx_get_irq(tx_chn->tx_chn);
- if (tx_chn->irq <= 0) {
+ if (tx_chn->irq < 0) {
dev_err(dev, "Failed to get tx dma irq %d\n",
tx_chn->irq);
- ret = tx_chn->irq ?: -ENXIO;
+ ret = tx_chn->irq;
goto err;
}
diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
index 89c0c3449d98..3c611b9aaecf 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
@@ -317,9 +317,7 @@ static int prueth_init_tx_chns(struct prueth_emac *emac)
}
ret = k3_udma_glue_tx_get_irq(tx_chn->tx_chn);
- if (ret <= 0) {
- if (!ret)
- ret = -EINVAL;
+ if (ret < 0) {
netdev_err(ndev, "failed to get tx irq\n");
goto fail;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 3/3 net] dmaengine: ti: k3-udma-glue: clean up k3_udma_glue_tx_get_irq() return
2023-09-26 14:06 ` [PATCH 3/3 net] dmaengine: ti: k3-udma-glue: clean up k3_udma_glue_tx_get_irq() return Dan Carpenter
@ 2023-09-26 18:46 ` Roger Quadros
2023-09-28 7:50 ` Vinod Koul
1 sibling, 0 replies; 8+ messages in thread
From: Roger Quadros @ 2023-09-26 18:46 UTC (permalink / raw)
To: Dan Carpenter, Peter Ujfalusi
Cc: Vinod Koul, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Siddharth Vadapalli, Grygorii Strashko,
MD Danish Anwar, Andrew Lunn, Vignesh Raghavendra, dmaengine,
linux-kernel, netdev, kernel-janitors
On 26/09/2023 17:06, Dan Carpenter wrote:
> The k3_udma_glue_tx_get_irq() function currently returns negative error
> codes on error, zero on error and positive values for success. This
> complicates life for the callers who need to propagate the error code.
> Also GCC will not warn about unsigned comparisons when you check:
>
> if (unsigned_irq <= 0)
>
> All the callers have been fixed now but let's just make this easy going
> forward.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3 net] dmaengine: ti: k3-udma-glue: clean up k3_udma_glue_tx_get_irq() return
2023-09-26 14:06 ` [PATCH 3/3 net] dmaengine: ti: k3-udma-glue: clean up k3_udma_glue_tx_get_irq() return Dan Carpenter
2023-09-26 18:46 ` Roger Quadros
@ 2023-09-28 7:50 ` Vinod Koul
1 sibling, 0 replies; 8+ messages in thread
From: Vinod Koul @ 2023-09-28 7:50 UTC (permalink / raw)
To: Dan Carpenter
Cc: Peter Ujfalusi, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Siddharth Vadapalli, Roger Quadros,
Grygorii Strashko, MD Danish Anwar, Andrew Lunn,
Vignesh Raghavendra, dmaengine, linux-kernel, netdev,
kernel-janitors
On 26-09-23, 17:06, Dan Carpenter wrote:
> The k3_udma_glue_tx_get_irq() function currently returns negative error
> codes on error, zero on error and positive values for success. This
> complicates life for the callers who need to propagate the error code.
> Also GCC will not warn about unsigned comparisons when you check:
>
> if (unsigned_irq <= 0)
>
> All the callers have been fixed now but let's just make this easy going
> forward.
Acked-by: Vinod Koul <vkoul@kernel.org>
--
~Vinod
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3 net] net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns()
2023-09-26 14:04 [PATCH 1/3 net] net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns() Dan Carpenter
2023-09-26 14:05 ` [PATCH 2/3 net] net: ti: icssg-prueth: Fix signedness bug in prueth_init_tx_chns() Dan Carpenter
2023-09-26 14:06 ` [PATCH 3/3 net] dmaengine: ti: k3-udma-glue: clean up k3_udma_glue_tx_get_irq() return Dan Carpenter
@ 2023-09-26 18:44 ` Roger Quadros
2023-10-04 9:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 8+ messages in thread
From: Roger Quadros @ 2023-09-26 18:44 UTC (permalink / raw)
To: Dan Carpenter, Grygorii Strashko
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Siddharth Vadapalli, netdev, kernel-janitors
On 26/09/2023 17:04, Dan Carpenter wrote:
> This accidentally returns success, but it should return a negative error
> code.
>
> Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 1/3 net] net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns()
2023-09-26 14:04 [PATCH 1/3 net] net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns() Dan Carpenter
` (2 preceding siblings ...)
2023-09-26 18:44 ` [PATCH 1/3 net] net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns() Roger Quadros
@ 2023-10-04 9:40 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-10-04 9:40 UTC (permalink / raw)
To: Dan Carpenter
Cc: grygorii.strashko, davem, edumazet, kuba, pabeni, rogerq,
s-vadapalli, netdev, kernel-janitors
Hello:
This series was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Tue, 26 Sep 2023 17:04:43 +0300 you wrote:
> This accidentally returns success, but it should return a negative error
> code.
>
> Fixes: 93a76530316a ("net: ethernet: ti: introduce am65x/j721e gigabit eth subsystem driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> Sorry for the delay on this. I wrote this before traveling and meant
> to send it earlier but forgot.
>
> [...]
Here is the summary with links:
- [1/3,net] net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns()
https://git.kernel.org/netdev/net/c/37d4f5556798
- [2/3,net] net: ti: icssg-prueth: Fix signedness bug in prueth_init_tx_chns()
https://git.kernel.org/netdev/net/c/a325f174d708
- [3/3,net] dmaengine: ti: k3-udma-glue: clean up k3_udma_glue_tx_get_irq() return
https://git.kernel.org/netdev/net/c/f9a1d3216a49
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 8+ messages in thread