diff mbox series

[net] rtase: Fix a check for error in rtase_alloc_msix()

Message ID f2ecc88d-af13-4651-9820-7cc665230019@stanley.mountain (mailing list archive)
State Accepted
Commit 2055272e3ae01a954e41a5afb437c5d76f758e0b
Delegated to: Netdev Maintainers
Headers show
Series [net] rtase: Fix a check for error in rtase_alloc_msix() | 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: 1 this patch: 1
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 2 this patch: 2
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: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 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
netdev/contest success net-next-2025-01-09--15-00 (tests: 882)

Commit Message

Dan Carpenter Jan. 8, 2025, 9:15 a.m. UTC
The pci_irq_vector() function never returns zero.  It returns negative
error codes or a positive non-zero IRQ number.  Fix the error checking to
test for negatives.

Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
For more information about the history of IRQ returns see my blog:
https://staticthinking.wordpress.com/2023/08/07/writing-a-check-for-zero-irq-error-codes/

 drivers/net/ethernet/realtek/rtase/rtase_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman Jan. 8, 2025, 10:42 a.m. UTC | #1
On Wed, Jan 08, 2025 at 12:15:53PM +0300, Dan Carpenter wrote:
> The pci_irq_vector() function never returns zero.  It returns negative
> error codes or a positive non-zero IRQ number.  Fix the error checking to
> test for negatives.
> 
> Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Simon Horman <horms@kernel.org>
Kalesh Anakkur Purayil Jan. 8, 2025, 12:16 p.m. UTC | #2
On Wed, Jan 8, 2025 at 2:46 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> The pci_irq_vector() function never returns zero.  It returns negative
> error codes or a positive non-zero IRQ number.  Fix the error checking to
> test for negatives.
>
> Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

LGTM,
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
patchwork-bot+netdevbpf@kernel.org Jan. 9, 2025, 4:30 p.m. UTC | #3
Hello:

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

On Wed, 8 Jan 2025 12:15:53 +0300 you wrote:
> The pci_irq_vector() function never returns zero.  It returns negative
> error codes or a positive non-zero IRQ number.  Fix the error checking to
> test for negatives.
> 
> Fixes: a36e9f5cfe9e ("rtase: Add support for a pci table in this module")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> 
> [...]

Here is the summary with links:
  - [net] rtase: Fix a check for error in rtase_alloc_msix()
    https://git.kernel.org/netdev/net/c/2055272e3ae0

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
index 585d0b21c9e0..3bd11cb56294 100644
--- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
+++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
@@ -1828,7 +1828,7 @@  static int rtase_alloc_msix(struct pci_dev *pdev, struct rtase_private *tp)
 
 	for (i = 0; i < tp->int_nums; i++) {
 		irq = pci_irq_vector(pdev, i);
-		if (!irq) {
+		if (irq < 0) {
 			pci_disable_msix(pdev);
 			return irq;
 		}