* [PATCH v2 net-next] ice: Fix signedness bug in ice_init_interrupt_scheme()
@ 2025-02-13 6:31 Dan Carpenter
2025-02-13 6:55 ` Michal Swiatkowski
2025-02-15 3:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-02-13 6:31 UTC (permalink / raw)
To: Michal Swiatkowski
Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Wojciech Drewek,
Jacob Keller, intel-wired-lan, netdev, linux-kernel,
kernel-janitors
If pci_alloc_irq_vectors() can't allocate the minimum number of vectors
then it returns -ENOSPC so there is no need to check for that in the
caller. In fact, because pf->msix.min is an unsigned int, it means that
any negative error codes are type promoted to high positive values and
treated as success. So here, the "return -ENOMEM;" is unreachable code.
Check for negatives instead.
Now that we're only dealing with error codes, it's easier to propagate
the error code from pci_alloc_irq_vectors() instead of hardcoding
-ENOMEM.
Fixes: 79d97b8cf9a8 ("ice: remove splitting MSI-X between features")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
v2: Fix my scripts to say [PATCH net-next]
Propagate the error code.
drivers/net/ethernet/intel/ice/ice_irq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_irq.c b/drivers/net/ethernet/intel/ice/ice_irq.c
index cbae3d81f0f1..30801fd375f0 100644
--- a/drivers/net/ethernet/intel/ice/ice_irq.c
+++ b/drivers/net/ethernet/intel/ice/ice_irq.c
@@ -149,8 +149,8 @@ int ice_init_interrupt_scheme(struct ice_pf *pf)
vectors = pci_alloc_irq_vectors(pf->pdev, pf->msix.min, vectors,
PCI_IRQ_MSIX);
- if (vectors < pf->msix.min)
- return -ENOMEM;
+ if (vectors < 0)
+ return vectors;
ice_init_irq_tracker(pf, pf->msix.max, vectors);
--
2.47.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 net-next] ice: Fix signedness bug in ice_init_interrupt_scheme()
2025-02-13 6:31 [PATCH v2 net-next] ice: Fix signedness bug in ice_init_interrupt_scheme() Dan Carpenter
@ 2025-02-13 6:55 ` Michal Swiatkowski
2025-02-15 3:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Michal Swiatkowski @ 2025-02-13 6:55 UTC (permalink / raw)
To: Dan Carpenter
Cc: Michal Swiatkowski, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Wojciech Drewek, Jacob Keller, intel-wired-lan, netdev,
linux-kernel, kernel-janitors
On Thu, Feb 13, 2025 at 09:31:41AM +0300, Dan Carpenter wrote:
> If pci_alloc_irq_vectors() can't allocate the minimum number of vectors
> then it returns -ENOSPC so there is no need to check for that in the
> caller. In fact, because pf->msix.min is an unsigned int, it means that
> any negative error codes are type promoted to high positive values and
> treated as success. So here, the "return -ENOMEM;" is unreachable code.
> Check for negatives instead.
>
> Now that we're only dealing with error codes, it's easier to propagate
> the error code from pci_alloc_irq_vectors() instead of hardcoding
> -ENOMEM.
>
> Fixes: 79d97b8cf9a8 ("ice: remove splitting MSI-X between features")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> v2: Fix my scripts to say [PATCH net-next]
> Propagate the error code.
>
> drivers/net/ethernet/intel/ice/ice_irq.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_irq.c b/drivers/net/ethernet/intel/ice/ice_irq.c
> index cbae3d81f0f1..30801fd375f0 100644
> --- a/drivers/net/ethernet/intel/ice/ice_irq.c
> +++ b/drivers/net/ethernet/intel/ice/ice_irq.c
> @@ -149,8 +149,8 @@ int ice_init_interrupt_scheme(struct ice_pf *pf)
>
> vectors = pci_alloc_irq_vectors(pf->pdev, pf->msix.min, vectors,
> PCI_IRQ_MSIX);
> - if (vectors < pf->msix.min)
> - return -ENOMEM;
> + if (vectors < 0)
> + return vectors;
>
> ice_init_irq_tracker(pf, pf->msix.max, vectors);
>
Thanks,
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> --
> 2.47.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 net-next] ice: Fix signedness bug in ice_init_interrupt_scheme()
2025-02-13 6:31 [PATCH v2 net-next] ice: Fix signedness bug in ice_init_interrupt_scheme() Dan Carpenter
2025-02-13 6:55 ` Michal Swiatkowski
@ 2025-02-15 3:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-15 3:50 UTC (permalink / raw)
To: Dan Carpenter
Cc: michal.swiatkowski, anthony.l.nguyen, przemyslaw.kitszel,
andrew+netdev, davem, edumazet, kuba, pabeni, wojciech.drewek,
jacob.e.keller, intel-wired-lan, netdev, linux-kernel,
kernel-janitors
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 13 Feb 2025 09:31:41 +0300 you wrote:
> If pci_alloc_irq_vectors() can't allocate the minimum number of vectors
> then it returns -ENOSPC so there is no need to check for that in the
> caller. In fact, because pf->msix.min is an unsigned int, it means that
> any negative error codes are type promoted to high positive values and
> treated as success. So here, the "return -ENOMEM;" is unreachable code.
> Check for negatives instead.
>
> [...]
Here is the summary with links:
- [v2,net-next] ice: Fix signedness bug in ice_init_interrupt_scheme()
https://git.kernel.org/netdev/net-next/c/c2ddb619fa8d
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] 3+ messages in thread
end of thread, other threads:[~2025-02-15 3:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-13 6:31 [PATCH v2 net-next] ice: Fix signedness bug in ice_init_interrupt_scheme() Dan Carpenter
2025-02-13 6:55 ` Michal Swiatkowski
2025-02-15 3:50 ` 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).