From: Jinjie Ruan <ruanjinjie@huawei.com>
To: "Nam Cao" <namcao@linutronix.de>,
"Nirmal Patel" <nirmal.patel@linux.intel.com>,
"Jonathan Derrick" <jonathan.derrick@linux.dev>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Kenneth Crudup <kenny@panix.com>, Ammar Faizi <ammarfaizi2@gnuweeb.org>
Subject: Re: [PATCH] PCI: vmd: Fix wrong kfree() in vmd_msi_free()
Date: Thu, 7 Aug 2025 20:24:27 +0800 [thread overview]
Message-ID: <8ffa0fe5-9657-31f0-6e72-246763e3b107@huawei.com> (raw)
In-Reply-To: <20250807063857.2175355-1-namcao@linutronix.de>
On 2025/8/7 14:38, Nam Cao wrote:
> vmd_msi_alloc() allocates struct vmd_irq and stashes it into
> irq_domain->irq-data->chip_data. vmd_msi_free() extracts the pointer by
> calling irq_get_chip_data() and frees it.
>
> irq_get_chip_data() returns the chip_data of the top interrupt domain. This
> worked in the past, because VMD's interrupt domain was the top domain.
>
> But since commit d7d8ab87e3e7 ("PCI: vmd: Switch to
> msi_create_parent_irq_domain()") changed the interrupt domain hierarchy,
> VMD's interrupt domain is not the top domain anymore. irq_get_chip_data()
> now returns the chip_data of the MSI devices' interrupt domain. It is
> therefore broken for vmd_msi_free() to kfree() this irq_data.
>
> Fix this issue, correctly extract the chip_data of VMD's interrupt domain.
>
> Fixes: d7d8ab87e3e7 ("PCI: vmd: Switch to msi_create_parent_irq_domain()")
> Reported-by: Kenneth Crudup <kenny@panix.com>
> Closes: https://lore.kernel.org/linux-pci/dfa40e48-8840-4e61-9fda-25cdb3ad81c1@panix.com/
> Reported-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
> Closes: https://lore.kernel.org/linux-pci/ed53280ed15d1140700b96cca2734bf327ee92539e5eb68e80f5bbbf0f01@linux.gnuweeb.org/
> Tested-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
> Tested-by: Kenneth Crudup <kenny@panix.com>
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> ---
> drivers/pci/controller/vmd.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
> index 9bbb0ff4cc15..b679c7f28f51 100644
> --- a/drivers/pci/controller/vmd.c
> +++ b/drivers/pci/controller/vmd.c
> @@ -280,10 +280,12 @@ static int vmd_msi_alloc(struct irq_domain *domain, unsigned int virq,
> static void vmd_msi_free(struct irq_domain *domain, unsigned int virq,
> unsigned int nr_irqs)
> {
> + struct irq_data *irq_data;
> struct vmd_irq *vmdirq;
>
> for (int i = 0; i < nr_irqs; ++i) {
> - vmdirq = irq_get_chip_data(virq + i);
> + irq_data = irq_domain_get_irq_data(domain, virq + i);
> + vmdirq = irq_data->chip_data;
Reviewed-by: Jinjie Ruan <ruanjinjie@huawei.com>
>
> synchronize_srcu(&vmdirq->irq->srcu);
>
prev parent reply other threads:[~2025-08-07 12:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-07 6:38 Nam Cao
2025-08-07 9:02 ` Thomas Gleixner
2025-08-07 12:24 ` Jinjie Ruan [this message]
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=8ffa0fe5-9657-31f0-6e72-246763e3b107@huawei.com \
--to=ruanjinjie@huawei.com \
--cc=ammarfaizi2@gnuweeb.org \
--cc=bhelgaas@google.com \
--cc=jonathan.derrick@linux.dev \
--cc=kenny@panix.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=namcao@linutronix.de \
--cc=nirmal.patel@linux.intel.com \
--cc=robh@kernel.org \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®