Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Anand Moon <linux.amoon@gmail.com>
Cc: "Kevin Xie" <kevin.xie@starfivetech.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Rob Herring" <robh@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	"Minda Chen" <minda.chen@starfivetech.com>,
	"open list:PCIE DRIVER FOR STARFIVE JH71x0"
	<linux-pci@vger.kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] PCI: starfive: Fix kmemleak in StarFive PCIe driver's IRQ handling
Date: Mon, 24 Feb 2025 13:31:29 +0530	[thread overview]
Message-ID: <20250224080129.zm7fvxermgeyycav@thinkpad> (raw)
In-Reply-To: <CANAwSgRvT-Mqj3XPrME6oKhYmnCUZLnwHfFHmSL=PK+xVLHAqw@mail.gmail.com>

On Thu, Feb 20, 2025 at 03:53:31PM +0530, Anand Moon wrote:

[...]

> Following the change fix this warning in a kernel memory leak.
> Would you happen to have any comments on these changes?
> 
> diff --git a/drivers/pci/controller/plda/pcie-plda-host.c
> b/drivers/pci/controller/plda/pcie-plda-host.c
> index 4153214ca410..5a72a5a33074 100644
> --- a/drivers/pci/controller/plda/pcie-plda-host.c
> +++ b/drivers/pci/controller/plda/pcie-plda-host.c
> @@ -280,11 +280,6 @@ static u32 plda_get_events(struct plda_pcie_rp *port)
>         return events;
>  }
> 
> -static irqreturn_t plda_event_handler(int irq, void *dev_id)
> -{
> -       return IRQ_HANDLED;
> -}
> -
>  static void plda_handle_event(struct irq_desc *desc)
>  {
>         struct plda_pcie_rp *port = irq_desc_get_handler_data(desc);
> @@ -454,13 +449,10 @@ int plda_init_interrupts(struct platform_device *pdev,
> 
>                 if (event->request_event_irq)
>                         ret = event->request_event_irq(port, event_irq, i);
> -               else
> -                       ret = devm_request_irq(dev, event_irq,
> -                                              plda_event_handler,
> -                                              0, NULL, port);

This change is not related to the memleak. But I'd like to have it in a separate
patch since this code is absolutely not required, rather pointless.

> 
>                 if (ret) {
>                         dev_err(dev, "failed to request IRQ %d\n", event_irq);
> +                       irq_dispose_mapping(event_irq);

So the issue overall is that the 'devm_request_irq' fails on your platform
because the interrupts are not defined in DT and then the IRQ is not disposed in
the error path?

In that case, none of the error paths below for_each_set_bit() loop is disposing
the IRQs. Also, calling 'irq_dispose_mapping()' only once is not going to
dispose all mappings that were created before in the loop.

- Mani

-- 
மணிவண்ணன் சதாசிவம்

  reply	other threads:[~2025-02-24  8:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-08 14:01 [PATCH v1] PCI: starfive: Fix kmemleak in StarFive PCIe driver's IRQ handling Anand Moon
2025-02-08 16:33 ` [PATCH] " Markus Elfring
2025-02-09  4:22   ` Anand Moon
2025-02-10 17:44 ` [PATCH v1] " Manivannan Sadhasivam
2025-02-10 19:39   ` Anand Moon
2025-02-14  6:09     ` Manivannan Sadhasivam
2025-02-20  8:13       ` Anand Moon
2025-02-20 10:23         ` Anand Moon
2025-02-24  8:01           ` Manivannan Sadhasivam [this message]
2025-02-24 10:08             ` Anand Moon
2025-02-24 11:54               ` Manivannan Sadhasivam
2025-02-24 14:03                 ` Anand Moon
2025-02-24 14:41                   ` Manivannan Sadhasivam
2025-02-24 16:07                     ` Anand Moon
2025-03-03 15:23                       ` Manivannan Sadhasivam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250224080129.zm7fvxermgeyycav@thinkpad \
    --to=manivannan.sadhasivam@linaro.org \
    --cc=bhelgaas@google.com \
    --cc=conor.dooley@microchip.com \
    --cc=kevin.xie@starfivetech.com \
    --cc=kw@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux.amoon@gmail.com \
    --cc=lpieralisi@kernel.org \
    --cc=minda.chen@starfivetech.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox