From: Michael Ellerman <mpe@ellerman.id.au>
To: Ganesh Goudar <ganeshgr@linux.ibm.com>, linuxppc-dev@lists.ozlabs.org
Cc: Ganesh Goudar <ganeshgr@linux.ibm.com>,
mahesh@linux.ibm.com, wenxiong@us.ibm.com
Subject: Re: [PATCH] powerpc/eeh: avoid possible crash when edev->pdev changes
Date: Tue, 11 Jun 2024 12:48:51 +1000 [thread overview]
Message-ID: <87cyoop52k.fsf@mail.lhotse> (raw)
In-Reply-To: <20240527075433.415693-1-ganeshgr@linux.ibm.com>
Hi Ganesh,
Ganesh Goudar <ganeshgr@linux.ibm.com> writes:
> If a PCI device is removed during eeh_pe_report_edev(), edev->pdev
> will change and can cause a crash, hold the PCI rescan/remove lock
> while taking a copy of edev->pdev.
>
> Signed-off-by: Ganesh Goudar <ganeshgr@linux.ibm.com>
> ---
> arch/powerpc/kernel/eeh_pe.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
> index d1030bc52564..49f968733912 100644
> --- a/arch/powerpc/kernel/eeh_pe.c
> +++ b/arch/powerpc/kernel/eeh_pe.c
> @@ -859,7 +859,9 @@ struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe)
>
> /* Retrieve the parent PCI bus of first (top) PCI device */
> edev = list_first_entry_or_null(&pe->edevs, struct eeh_dev, entry);
> + pci_lock_rescan_remove();
> pdev = eeh_dev_to_pci_dev(edev);
> + pci_unlock_rescan_remove();
> if (pdev)
> return pdev->bus;
What prevents pdev being freed/reused immediately after you drop the
rescan/remove lock?
AFAICS eeh_dev_to_pci_dev() doesn't take an additional reference to the
pdev or anything.
cheers
next prev parent reply other threads:[~2024-06-11 2:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 7:54 [PATCH] powerpc/eeh: avoid possible crash when edev->pdev changes Ganesh Goudar
2024-06-11 2:48 ` Michael Ellerman [this message]
2024-06-13 13:48 ` Ganesh G R
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=87cyoop52k.fsf@mail.lhotse \
--to=mpe@ellerman.id.au \
--cc=ganeshgr@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mahesh@linux.ibm.com \
--cc=wenxiong@us.ibm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.