* [PATCH next] ice, irdma: fix an off by one in error handling code
@ 2025-02-12 15:25 Dan Carpenter
2025-02-13 5:47 ` Michal Swiatkowski
2025-02-14 19:47 ` Tony Nguyen
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-02-12 15:25 UTC (permalink / raw)
To: Michal Swiatkowski
Cc: Mustafa Ismail, Tatyana Nikolova, Jason Gunthorpe,
Leon Romanovsky, Tony Nguyen, Jacob Keller, linux-rdma,
linux-kernel, kernel-janitors
If we don't allocate the MIN number of IRQs then we need to free what
we have and return -ENOMEM. The problem is this loop is off by one
so it frees an entry that wasn't allocated and it doesn't free the
first entry where i == 0.
Fixes: 3e0d3cb3fbe0 ("ice, irdma: move interrupts code to irdma")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/infiniband/hw/irdma/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/irdma/main.c b/drivers/infiniband/hw/irdma/main.c
index 1ee8969595d3..5fc081ca8905 100644
--- a/drivers/infiniband/hw/irdma/main.c
+++ b/drivers/infiniband/hw/irdma/main.c
@@ -221,7 +221,7 @@ static int irdma_init_interrupts(struct irdma_pci_f *rf, struct ice_pf *pf)
break;
if (i < IRDMA_MIN_MSIX) {
- for (; i > 0; i--)
+ while (--i >= 0)
ice_free_rdma_qvector(pf, &rf->msix_entries[i]);
kfree(rf->msix_entries);
--
2.47.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH next] ice, irdma: fix an off by one in error handling code
2025-02-12 15:25 [PATCH next] ice, irdma: fix an off by one in error handling code Dan Carpenter
@ 2025-02-13 5:47 ` Michal Swiatkowski
2025-02-14 19:47 ` Tony Nguyen
1 sibling, 0 replies; 3+ messages in thread
From: Michal Swiatkowski @ 2025-02-13 5:47 UTC (permalink / raw)
To: Dan Carpenter
Cc: Michal Swiatkowski, Mustafa Ismail, Tatyana Nikolova,
Jason Gunthorpe, Leon Romanovsky, Tony Nguyen, Jacob Keller,
linux-rdma, linux-kernel, kernel-janitors
On Wed, Feb 12, 2025 at 06:25:44PM +0300, Dan Carpenter wrote:
> If we don't allocate the MIN number of IRQs then we need to free what
> we have and return -ENOMEM. The problem is this loop is off by one
> so it frees an entry that wasn't allocated and it doesn't free the
> first entry where i == 0.
>
> Fixes: 3e0d3cb3fbe0 ("ice, irdma: move interrupts code to irdma")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/infiniband/hw/irdma/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/hw/irdma/main.c b/drivers/infiniband/hw/irdma/main.c
> index 1ee8969595d3..5fc081ca8905 100644
> --- a/drivers/infiniband/hw/irdma/main.c
> +++ b/drivers/infiniband/hw/irdma/main.c
> @@ -221,7 +221,7 @@ static int irdma_init_interrupts(struct irdma_pci_f *rf, struct ice_pf *pf)
> break;
>
> if (i < IRDMA_MIN_MSIX) {
> - for (; i > 0; i--)
> + while (--i >= 0)
> ice_free_rdma_qvector(pf, &rf->msix_entries[i]);
>
> kfree(rf->msix_entries);
Przemek pointed that in the review, but somehow I missed that :( .
Thanks for fixing:
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> --
> 2.47.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH next] ice, irdma: fix an off by one in error handling code
2025-02-12 15:25 [PATCH next] ice, irdma: fix an off by one in error handling code Dan Carpenter
2025-02-13 5:47 ` Michal Swiatkowski
@ 2025-02-14 19:47 ` Tony Nguyen
1 sibling, 0 replies; 3+ messages in thread
From: Tony Nguyen @ 2025-02-14 19:47 UTC (permalink / raw)
To: Dan Carpenter, Michal Swiatkowski
Cc: Mustafa Ismail, Tatyana Nikolova, Jason Gunthorpe,
Leon Romanovsky, Jacob Keller, linux-rdma, linux-kernel,
kernel-janitors
On 2/12/2025 7:25 AM, Dan Carpenter wrote:
> If we don't allocate the MIN number of IRQs then we need to free what
> we have and return -ENOMEM. The problem is this loop is off by one
> so it frees an entry that wasn't allocated and it doesn't free the
> first entry where i == 0.
>
> Fixes: 3e0d3cb3fbe0 ("ice, irdma: move interrupts code to irdma")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Thanks for the patch Dan. I've applied this to iwl-next since it
originated from there and I'd like to bundle this with the other fixes
related to the series.
Thanks,
Tony
> ---
> drivers/infiniband/hw/irdma/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/hw/irdma/main.c b/drivers/infiniband/hw/irdma/main.c
> index 1ee8969595d3..5fc081ca8905 100644
> --- a/drivers/infiniband/hw/irdma/main.c
> +++ b/drivers/infiniband/hw/irdma/main.c
> @@ -221,7 +221,7 @@ static int irdma_init_interrupts(struct irdma_pci_f *rf, struct ice_pf *pf)
> break;
>
> if (i < IRDMA_MIN_MSIX) {
> - for (; i > 0; i--)
> + while (--i >= 0)
> ice_free_rdma_qvector(pf, &rf->msix_entries[i]);
>
> kfree(rf->msix_entries);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-14 19:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-12 15:25 [PATCH next] ice, irdma: fix an off by one in error handling code Dan Carpenter
2025-02-13 5:47 ` Michal Swiatkowski
2025-02-14 19:47 ` Tony Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox