* [PATCH net-next] e1000e: fix memory leak of msix_entries on MSI-X failure
@ 2026-05-23 6:22 Ashwin Gundarapu
2026-05-25 8:41 ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-05-26 20:01 ` Simon Horman
0 siblings, 2 replies; 4+ messages in thread
From: Ashwin Gundarapu @ 2026-05-23 6:22 UTC (permalink / raw)
To: anthonylnguyen, anthony.l.nguyen@intel•com, andrewnetdev, davem,
edumazet, kuba, pabeni
Cc: intel-wired-lan, netdev, linux-kernel
From: Ashwin Gundarapu <linuxuser509@zohomail•in>
Date: Sat, 23 May 2026 11:49:40 +0530
Subject: [PATCH] e1000e: fix memory leak of msix_entries on MSI-X failure
When MSI-X initialization fails, the driver falls through to try
MSI or legacy interrupts. However, the msix_entries array allocated
earlier is not freed, causing a memory leak. Free it and set to
NULL before falling through to the MSI fallback path.
Found by code inspection.
Signed-off-by: Ashwin Gundarapu <linuxuser509@zohomail•in>
---
drivers/net/ethernet/intel/e1000e/netdev.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 7ce0cc8ab8f4..1526069d7fc1 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -2065,10 +2065,12 @@ void e1000e_set_interrupt_capability(struct e1000_adapter *adapter)
a->num_vectors);
if (err > 0)
return;
- }
- /* MSI-X failed, so fall through and try MSI */
- e_err("Failed to initialize MSI-X interrupts. Falling back to MSI interrupts.\n");
- e1000e_reset_interrupt_capability(adapter);
+ }
+ /* MSI-X failed, so fall through and try MSI */
+ e_err("Failed to initialize MSI-X interrupts. Falling back to MSI interrupts.\n");
+ kfree(adapter->msix_entries);
+ adapter->msix_entries = NULL;
+ e1000e_reset_interrupt_capability(adapter);
}
adapter->int_mode = E1000E_INT_MODE_MSI;
fallthrough;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [Intel-wired-lan] [PATCH net-next] e1000e: fix memory leak of msix_entries on MSI-X failure
2026-05-23 6:22 [PATCH net-next] e1000e: fix memory leak of msix_entries on MSI-X failure Ashwin Gundarapu
@ 2026-05-25 8:41 ` Loktionov, Aleksandr
2026-05-26 20:01 ` Simon Horman
1 sibling, 0 replies; 4+ messages in thread
From: Loktionov, Aleksandr @ 2026-05-25 8:41 UTC (permalink / raw)
To: Ashwin Gundarapu, Nguyen, Anthony L, Kitszel, Przemyslaw,
andrewnetdev, davem, edumazet, kuba, pabeni
Cc: intel-wired-lan, netdev, linux-kernel
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl•org> On Behalf
> Of Ashwin Gundarapu via Intel-wired-lan
> Sent: Saturday, May 23, 2026 8:22 AM
> To: Nguyen, Anthony L <anthony.l.nguyen@intel•com>; Kitszel,
> Przemyslaw <przemyslaw.kitszel@intel•com>; andrewnetdev
> <andrew+netdev@lunn•ch>; davem <davem@davemloft•net>; edumazet
> <edumazet@google•com>; kuba <kuba@kernel•org>; pabeni
> <pabeni@redhat•com>
> Cc: intel-wired-lan <intel-wired-lan@lists•osuosl.org>; netdev
> <netdev@vger•kernel.org>; linux-kernel <linux-kernel@vger•kernel.org>
> Subject: [Intel-wired-lan] [PATCH net-next] e1000e: fix memory leak of
> msix_entries on MSI-X failure
>
> From: Ashwin Gundarapu <linuxuser509@zohomail•in>
> Date: Sat, 23 May 2026 11:49:40 +0530
> Subject: [PATCH] e1000e: fix memory leak of msix_entries on MSI-X
> failure
>
> When MSI-X initialization fails, the driver falls through to try MSI
> or legacy interrupts. However, the msix_entries array allocated
> earlier is not freed, causing a memory leak. Free it and set to NULL
> before falling through to the MSI fallback path.
>
> Found by code inspection.
>
It sounds as serious bug, shouldn't it be for net ?
Then it needs proper Fixes tag and Cc: stable@vger•kernel.org
> Signed-off-by: Ashwin Gundarapu <linuxuser509@zohomail•in>
> ---
> drivers/net/ethernet/intel/e1000e/netdev.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c
> b/drivers/net/ethernet/intel/e1000e/netdev.c
> index 7ce0cc8ab8f4..1526069d7fc1 100644
> --- a/drivers/net/ethernet/intel/e1000e/netdev.c
> +++ b/drivers/net/ethernet/intel/e1000e/netdev.c
> @@ -2065,10 +2065,12 @@ void e1000e_set_interrupt_capability(struct
> e1000_adapter *adapter)
> a->num_vectors);
> if (err > 0)
> return;
> - }
> - /* MSI-X failed, so fall through and try MSI */
> - e_err("Failed to initialize MSI-X interrupts.
> Falling back to MSI interrupts.\n");
> - e1000e_reset_interrupt_capability(adapter);
> + }
> + /* MSI-X failed, so fall through and try MSI
> */
> + e_err("Failed to initialize MSI-X interrupts.
> Falling back to MSI interrupts.\n");
> + kfree(adapter->msix_entries);
> + adapter->msix_entries = NULL;
> + e1000e_reset_interrupt_capability(adapter);
Please use tabs instead of spaces.
> }
> adapter->int_mode = E1000E_INT_MODE_MSI;
> fallthrough;
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] e1000e: fix memory leak of msix_entries on MSI-X failure
2026-05-23 6:22 [PATCH net-next] e1000e: fix memory leak of msix_entries on MSI-X failure Ashwin Gundarapu
2026-05-25 8:41 ` [Intel-wired-lan] " Loktionov, Aleksandr
@ 2026-05-26 20:01 ` Simon Horman
2026-05-27 7:41 ` [Intel-wired-lan] " Loktionov, Aleksandr
1 sibling, 1 reply; 4+ messages in thread
From: Simon Horman @ 2026-05-26 20:01 UTC (permalink / raw)
To: Ashwin Gundarapu
Cc: anthonylnguyen, anthony.l.nguyen@intel•com, andrewnetdev, davem,
edumazet, kuba, pabeni, intel-wired-lan, netdev, linux-kernel
On Sat, May 23, 2026 at 11:52:14AM +0530, Ashwin Gundarapu wrote:
> From: Ashwin Gundarapu <linuxuser509@zohomail•in>
> Date: Sat, 23 May 2026 11:49:40 +0530
> Subject: [PATCH] e1000e: fix memory leak of msix_entries on MSI-X failure
>
> When MSI-X initialization fails, the driver falls through to try
> MSI or legacy interrupts. However, the msix_entries array allocated
> earlier is not freed, causing a memory leak. Free it and set to
> NULL before falling through to the MSI fallback path.
>
> Found by code inspection.
>
> Signed-off-by: Ashwin Gundarapu <linuxuser509@zohomail•in>
> ---
> drivers/net/ethernet/intel/e1000e/netdev.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
> index 7ce0cc8ab8f4..1526069d7fc1 100644
> --- a/drivers/net/ethernet/intel/e1000e/netdev.c
> +++ b/drivers/net/ethernet/intel/e1000e/netdev.c
> @@ -2065,10 +2065,12 @@ void e1000e_set_interrupt_capability(struct e1000_adapter *adapter)
> a->num_vectors);
> if (err > 0)
> return;
> - }
> - /* MSI-X failed, so fall through and try MSI */
> - e_err("Failed to initialize MSI-X interrupts. Falling back to MSI interrupts.\n");
> - e1000e_reset_interrupt_capability(adapter);
> + }
> + /* MSI-X failed, so fall through and try MSI */
> + e_err("Failed to initialize MSI-X interrupts. Falling back to MSI interrupts.\n");
> + kfree(adapter->msix_entries);
> + adapter->msix_entries = NULL;
> + e1000e_reset_interrupt_capability(adapter);
Hi Ashwin,
e1000e_reset_interrupt_capability() already handles freeing (and NULLing)
msix_entries, and it does so after calling pci_disable_msix().
This patch seems to have the effect of bypassing the call to
pci_disable_msix().
Are you sure this is fixing a memory leak as described?
Flagged by https://sashiko.dev/ and https://netdev-ai.bots.linux.dev/sashiko/
> }
> adapter->int_mode = E1000E_INT_MODE_MSI;
> fallthrough;
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [Intel-wired-lan] [PATCH net-next] e1000e: fix memory leak of msix_entries on MSI-X failure
2026-05-26 20:01 ` Simon Horman
@ 2026-05-27 7:41 ` Loktionov, Aleksandr
0 siblings, 0 replies; 4+ messages in thread
From: Loktionov, Aleksandr @ 2026-05-27 7:41 UTC (permalink / raw)
To: Simon Horman, Ashwin Gundarapu
Cc: Nguyen, Anthony L, Kitszel, Przemyslaw, andrewnetdev, davem,
edumazet, kuba, pabeni, intel-wired-lan, netdev, linux-kernel
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl•org> On Behalf
> Of Simon Horman
> Sent: Tuesday, May 26, 2026 10:01 PM
> To: Ashwin Gundarapu <linuxuser509@zohomail•in>
> Cc: Nguyen, Anthony L <anthony.l.nguyen@intel•com>; Kitszel,
> Przemyslaw <przemyslaw.kitszel@intel•com>; andrewnetdev
> <andrew+netdev@lunn•ch>; davem <davem@davemloft•net>; edumazet
> <edumazet@google•com>; kuba <kuba@kernel•org>; pabeni
> <pabeni@redhat•com>; intel-wired-lan <intel-wired-
> lan@lists•osuosl.org>; netdev <netdev@vger•kernel.org>; linux-kernel
> <linux-kernel@vger•kernel.org>
> Subject: Re: [Intel-wired-lan] [PATCH net-next] e1000e: fix memory
> leak of msix_entries on MSI-X failure
>
> On Sat, May 23, 2026 at 11:52:14AM +0530, Ashwin Gundarapu wrote:
> > From: Ashwin Gundarapu <linuxuser509@zohomail•in>
> > Date: Sat, 23 May 2026 11:49:40 +0530
> > Subject: [PATCH] e1000e: fix memory leak of msix_entries on MSI-X
> > failure
> >
> > When MSI-X initialization fails, the driver falls through to try MSI
> > or legacy interrupts. However, the msix_entries array allocated
> > earlier is not freed, causing a memory leak. Free it and set to NULL
> > before falling through to the MSI fallback path.
> >
> > Found by code inspection.
> >
> > Signed-off-by: Ashwin Gundarapu <linuxuser509@zohomail•in>
> > ---
> > drivers/net/ethernet/intel/e1000e/netdev.c | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c
> > b/drivers/net/ethernet/intel/e1000e/netdev.c
> > index 7ce0cc8ab8f4..1526069d7fc1 100644
> > --- a/drivers/net/ethernet/intel/e1000e/netdev.c
> > +++ b/drivers/net/ethernet/intel/e1000e/netdev.c
> > @@ -2065,10 +2065,12 @@ void e1000e_set_interrupt_capability(struct
> e1000_adapter *adapter)
> > a->num_vectors);
> > if (err > 0)
> > return;
> > - }
> > - /* MSI-X failed, so fall through and try MSI */
> > - e_err("Failed to initialize MSI-X interrupts.
> Falling back to MSI interrupts.\n");
> > - e1000e_reset_interrupt_capability(adapter);
> > + }
> > + /* MSI-X failed, so fall through and try
> MSI */
> > + e_err("Failed to initialize MSI-X
> interrupts. Falling back to MSI interrupts.\n");
> > + kfree(adapter->msix_entries);
> > + adapter->msix_entries = NULL;
> > + e1000e_reset_interrupt_capability(adapter);
>
> Hi Ashwin,
>
> e1000e_reset_interrupt_capability() already handles freeing (and
> NULLing) msix_entries, and it does so after calling
> pci_disable_msix().
>
> This patch seems to have the effect of bypassing the call to
> pci_disable_msix().
>
> Are you sure this is fixing a memory leak as described?
>
> Flagged by https://sashiko.dev/ and https://netdev-
> ai.bots.linux.dev/sashiko/
>
Good day, Ashwin
For me looks suspicious the call e1000e_reset_interrupt_capability() after you NULLified the adapter->msix_entries
Alex
> > }
> > adapter->int_mode = E1000E_INT_MODE_MSI;
> > fallthrough;
> > --
> > 2.43.0
> >
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-27 7:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-23 6:22 [PATCH net-next] e1000e: fix memory leak of msix_entries on MSI-X failure Ashwin Gundarapu
2026-05-25 8:41 ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-05-26 20:01 ` Simon Horman
2026-05-27 7:41 ` [Intel-wired-lan] " Loktionov, Aleksandr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox