diff mbox series

[net] net: ti: icssg-prueth: Fix signedness bug in prueth_init_rx_chns()

Message ID 05282415-e7f4-42f3-99f8-32fde8f30936@moroto.mountain (mailing list archive)
State Accepted
Commit 4dcd0e83ea1d1df9b2e0174a6d3e795b3477d64e
Delegated to: Netdev Maintainers
Headers show
Series [net] net: ti: icssg-prueth: Fix signedness bug in prueth_init_rx_chns() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Dan Carpenter April 23, 2024, 4:15 p.m. UTC
The rx_chn->irq[] array is unsigned int but it should be signed for the
error handling to work.  Also if k3_udma_glue_rx_get_irq() returns zero
then we should return -ENXIO instead of success.

Fixes: 128d5874c082 ("net: ti: icssg-prueth: Add ICSSG ethernet driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
I had previously fixed the issues with the tx_chns() version of this but
I didn't realize there was an rx version.  These functions got moved
around in net-next so that's why I noticed this bug...  Moving the
code around makes applying this to net-next kind of pain.

 drivers/net/ethernet/ti/icssg/icssg_prueth.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Roger Quadros April 24, 2024, 7:27 a.m. UTC | #1
On 23/04/2024 19:15, Dan Carpenter wrote:
> The rx_chn->irq[] array is unsigned int but it should be signed for the
> error handling to work.  Also if k3_udma_glue_rx_get_irq() returns zero
> then we should return -ENXIO instead of success.
> 
> 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>
MD Danish Anwar April 24, 2024, 8:28 a.m. UTC | #2
On 23/04/24 9:45 pm, Dan Carpenter wrote:
> The rx_chn->irq[] array is unsigned int but it should be signed for the
> error handling to work.  Also if k3_udma_glue_rx_get_irq() returns zero
> then we should return -ENXIO instead of success.
> 
> Fixes: 128d5874c082 ("net: ti: icssg-prueth: Add ICSSG ethernet driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: MD Danish Anwar <danishanwar@ti.com>
patchwork-bot+netdevbpf@kernel.org April 25, 2024, 3:30 p.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 23 Apr 2024 19:15:22 +0300 you wrote:
> The rx_chn->irq[] array is unsigned int but it should be signed for the
> error handling to work.  Also if k3_udma_glue_rx_get_irq() returns zero
> then we should return -ENXIO instead of success.
> 
> Fixes: 128d5874c082 ("net: ti: icssg-prueth: Add ICSSG ethernet driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> 
> [...]

Here is the summary with links:
  - [net] net: ti: icssg-prueth: Fix signedness bug in prueth_init_rx_chns()
    https://git.kernel.org/netdev/net/c/4dcd0e83ea1d

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
index cf7b73f8f450..b69af69a1ccd 100644
--- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c
@@ -421,12 +421,14 @@  static int prueth_init_rx_chns(struct prueth_emac *emac,
 		if (!i)
 			fdqring_id = k3_udma_glue_rx_flow_get_fdq_id(rx_chn->rx_chn,
 								     i);
-		rx_chn->irq[i] = k3_udma_glue_rx_get_irq(rx_chn->rx_chn, i);
-		if (rx_chn->irq[i] <= 0) {
-			ret = rx_chn->irq[i];
+		ret = k3_udma_glue_rx_get_irq(rx_chn->rx_chn, i);
+		if (ret <= 0) {
+			if (!ret)
+				ret = -ENXIO;
 			netdev_err(ndev, "Failed to get rx dma irq");
 			goto fail;
 		}
+		rx_chn->irq[i] = ret;
 	}
 
 	return 0;