[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5bc32310f882c45d8713e324dd30cc1ca41ed20a.camel@redhat.com>
Date: Tue, 03 Dec 2024 19:25:17 -0500
From: Maxim Levitsky <mlevitsk@...hat.com>
To: Simon Horman <horms@...nel.org>, Michael Kelley <mhklinux@...look.com>
Cc: "kvm@...r.kernel.org" <kvm@...r.kernel.org>, Shradha Gupta
<shradhagupta@...ux.microsoft.com>, Wei Liu <wei.liu@...nel.org>, Haiyang
Zhang <haiyangz@...rosoft.com>, Konstantin Taranov
<kotaranov@...rosoft.com>, Yury Norov <yury.norov@...il.com>, "K. Y.
Srinivasan" <kys@...rosoft.com>, Eric Dumazet <edumazet@...gle.com>,
"linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>, Long Li
<longli@...rosoft.com>, Jakub Kicinski <kuba@...nel.org>, "David S. Miller"
<davem@...emloft.net>, Leon Romanovsky <leon@...nel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>, Paolo Abeni
<pabeni@...hat.com>, Andrew Lunn <andrew+netdev@...n.ch>, Souradeep
Chakrabarti <schakrabarti@...ux.microsoft.com>, Dexuan Cui
<decui@...rosoft.com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] net: mana: Fix memory leak in mana_gd_setup_irqs
On Tue, 2024-12-03 at 16:21 +0000, Simon Horman wrote:
> On Thu, Nov 28, 2024 at 09:49:35PM +0000, Michael Kelley wrote:
> > From: Maxim Levitsky <mlevitsk@...hat.com> Sent: Thursday, November 28, 2024 11:43 AM
> > > Commit 8afefc361209 ("net: mana: Assigning IRQ affinity on HT cores")
> > > added memory allocation in mana_gd_setup_irqs of 'irqs' but the code
> > > doesn't free this temporary array in the success path.
> > >
> > > This was caught by kmemleak.
> > >
> > > Fixes: 8afefc361209 ("net: mana: Assigning IRQ affinity on HT cores")
> > > Signed-off-by: Maxim Levitsky <mlevitsk@...hat.com>
> > > ---
> > > drivers/net/ethernet/microsoft/mana/gdma_main.c | 1 +
> > > 1 file changed, 1 insertion(+)
> > >
> > > diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c
> > > b/drivers/net/ethernet/microsoft/mana/gdma_main.c
> > > index e97af7ac2bb2..aba188f9f10f 100644
> > > --- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
> > > +++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
> > > @@ -1375,6 +1375,7 @@ static int mana_gd_setup_irqs(struct pci_dev *pdev)
> > > gc->max_num_msix = nvec;
> > > gc->num_msix_usable = nvec;
> > > cpus_read_unlock();
> > > + kfree(irqs);
> > > return 0;
> > >
> > > free_irq:
> >
> > FWIW, there's a related error path leak. If the kcalloc() to populate
> > gc->irq_contexts fails, the irqs array is not freed. Probably could
> > extend this patch to fix that leak as well.
>
> Yes, as that problem also appears to be introduced by the cited commit
> I agree it would be good to fix them both in one patch.
>
I'll send a v2 tomorrow. Thanks for the review!
Best regards,
Maxim Levitsky
Powered by blists - more mailing lists