netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] rtase: Fix a check for error in rtase_alloc_msix()
@ 2025-01-08  9:15 Dan Carpenter
  2025-01-08 10:42 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-01-08  9:15 UTC (permalink / raw)
  To: Justin Lai
  Cc: Larry Chiu, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, netdev, linux-kernel,
	kernel-janitors

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(-)

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;
 		}
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] rtase: Fix a check for error in rtase_alloc_msix()
  2025-01-08  9:15 [PATCH net] rtase: Fix a check for error in rtase_alloc_msix() Dan Carpenter
@ 2025-01-08 10:42 ` Simon Horman
  2025-01-08 12:16 ` Kalesh Anakkur Purayil
  2025-01-09 16:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2025-01-08 10:42 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Justin Lai, Larry Chiu, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel,
	kernel-janitors

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>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] rtase: Fix a check for error in rtase_alloc_msix()
  2025-01-08  9:15 [PATCH net] rtase: Fix a check for error in rtase_alloc_msix() Dan Carpenter
  2025-01-08 10:42 ` Simon Horman
@ 2025-01-08 12:16 ` Kalesh Anakkur Purayil
  2025-01-09 16:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Kalesh Anakkur Purayil @ 2025-01-08 12:16 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Justin Lai, Larry Chiu, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel,
	kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 499 bytes --]

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>


-- 
Regards,
Kalesh AP

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4239 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] rtase: Fix a check for error in rtase_alloc_msix()
  2025-01-08  9:15 [PATCH net] rtase: Fix a check for error in rtase_alloc_msix() Dan Carpenter
  2025-01-08 10:42 ` Simon Horman
  2025-01-08 12:16 ` Kalesh Anakkur Purayil
@ 2025-01-09 16:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-01-09 16:30 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: justinlai0215, larry.chiu, andrew+netdev, davem, edumazet, kuba,
	pabeni, netdev, linux-kernel, kernel-janitors

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-09 16:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-08  9:15 [PATCH net] rtase: Fix a check for error in rtase_alloc_msix() Dan Carpenter
2025-01-08 10:42 ` Simon Horman
2025-01-08 12:16 ` Kalesh Anakkur Purayil
2025-01-09 16:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).