Re: [PATCH net-next] e1000e: fix memory leak of msix_entries on MSI-X failure
From: Ashwin Gundarapu
Date: Wed Jun 10 2026 - 08:44:15 EST
Simon, you're right. e1000e_reset_interrupt_capability already frees msix_entries. I'll drop this patch.
Thanks,
Ashwin Gundarapu
From: Simon Horman <horms@xxxxxxxxxx>
To: "Ashwin Gundarapu"<linuxuser509@xxxxxxxxxxx>
Cc: "anthonylnguyen"<anthony.l.nguyen@xxxxxxxxx>, "anthony.l.nguyen@xxxxxxxxx"<przemyslaw.kitszel@xxxxxxxxx>, "andrewnetdev"<andrew+netdev@xxxxxxx>, "davem"<davem@xxxxxxxxxxxxx>, "edumazet"<edumazet@xxxxxxxxxx>, "kuba"<kuba@xxxxxxxxxx>, "pabeni"<pabeni@xxxxxxxxxx>, "intel-wired-lan"<intel-wired-lan@xxxxxxxxxxxxxxxx>, "netdev"<netdev@xxxxxxxxxxxxxxx>, "linux-kernel"<linux-kernel@xxxxxxxxxxxxxxx>
Date: Wed, 27 May 2026 01:31:14 +0530
Subject: Re: [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@xxxxxxxxxxx>
> > 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@xxxxxxxxxxx>
> > ---
> > 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
> >
> >
>
>