Message ID | 20241209175751.287738-2-mlevitsk@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | MANA: Fix few memory leaks in mana_gd_setup_irqs | expand |
On Mon, Dec 09, 2024 at 12:57:50PM -0500, Maxim Levitsky wrote: > 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@redhat.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); Ther is still memleak in case of jumping to free_irq_vector when gc->irq_contexts allocation is failing. Thanks > return 0; > > free_irq: > -- > 2.26.3
On Tue, Dec 10, 2024 at 07:13:53AM +0100, Michal Swiatkowski wrote: > On Mon, Dec 09, 2024 at 12:57:50PM -0500, Maxim Levitsky wrote: > > 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@redhat.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); > > Ther is still memleak in case of jumping to free_irq_vector when > gc->irq_contexts allocation is failing. > Ignore that, just took a look at second patch. Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> > Thanks > > return 0; > > > > free_irq: > > -- > > 2.26.3
On Mon, Dec 9, 2024 at 11:28 PM Maxim Levitsky <mlevitsk@redhat.com> wrote: > > 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@redhat.com> LGTM Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
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:
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@redhat.com> --- drivers/net/ethernet/microsoft/mana/gdma_main.c | 1 + 1 file changed, 1 insertion(+)