Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>,
	Tony Nguyen <anthony.l.nguyen@intel.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	 Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	Jacob Keller <jacob.e.keller@intel.com>,
	"Wojciech Drewek" <wojciech.drewek@intel.com>,
	<intel-wired-lan@lists.osuosl.org>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <kernel-janitors@vger.kernel.org>
Subject: Re: [Intel-wired-lan] [PATCH next] ice: Fix signedness bug in ice_init_interrupt_scheme()
Date: Wed, 12 Feb 2025 17:46:54 +0100	[thread overview]
Message-ID: <f66b15a3-1d83-43f9-8af2-071b76b133c0@intel.com> (raw)
In-Reply-To: <14ebc311-6fd6-4b0b-b314-8347c4efd9fc@stanley.mountain>

From: Dan Carpenter <dan.carpenter@linaro.org>
Date: Wed, 12 Feb 2025 18:27:09 +0300

> [PATCH next] ice: Fix signedness bug in ice_init_interrupt_scheme()

I believe it should be "PATCH net" with

> 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.
> 
> Fixes: 79d97b8cf9a8 ("ice: remove splitting MSI-X between features")

a 'Stable:' tag here.

> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/net/ethernet/intel/ice/ice_irq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_irq.c b/drivers/net/ethernet/intel/ice/ice_irq.c
> index cbae3d81f0f1..b1fdad154203 100644
> --- a/drivers/net/ethernet/intel/ice/ice_irq.c
> +++ b/drivers/net/ethernet/intel/ice/ice_irq.c
> @@ -149,7 +149,7 @@ 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)
> +	if (vectors < 0)
>  		return -ENOMEM;

This pattern most likely repeats in other Intel drivers >_<

BTW it's a bit weird that we return -ENOMEM here, although we have a
precise errno in case of error. Shouldn't we do `return vectors` here?

(but this is more of an improvement, not a fix, so out of this patch's
 scope)

>  
>  	ice_init_irq_tracker(pf, pf->msix.max, vectors);

Thanks,
Olek

  reply	other threads:[~2025-02-12 16:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12 15:27 [Intel-wired-lan] [PATCH next] ice: Fix signedness bug in ice_init_interrupt_scheme() Dan Carpenter
2025-02-12 16:46 ` Alexander Lobakin [this message]
2025-02-13  1:59   ` Jakub Kicinski
2025-02-13  5:26     ` Dan Carpenter
2025-02-13  5:43       ` Michal Swiatkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f66b15a3-1d83-43f9-8af2-071b76b133c0@intel.com \
    --to=aleksander.lobakin@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=dan.carpenter@linaro.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jacob.e.keller@intel.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.swiatkowski@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=wojciech.drewek@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox