linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: bhelgaas@google.com, rafael@kernel.org,
	linux-kernel@vger.kernel.org, Len Brown <lenb@kernel.org>,
	linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org,
	whitehat002 <hackyzh002@gmail.com>
Subject: Re: [PATCH] PCI/ACPI: do not reference a pci device after it has been released
Date: Thu, 28 Apr 2022 10:58:58 -0500	[thread overview]
Message-ID: <20220428155858.GA14614@bhelgaas> (raw)
In-Reply-To: <20220428142854.1065953-1-gregkh@linuxfoundation.org>

On Thu, Apr 28, 2022 at 04:28:53PM +0200, Greg Kroah-Hartman wrote:
> In acpi_get_pci_dev(), the debugging message for when a PCI bridge is
> not found uses a pointer to a pci device whose reference has just been
> dropped.  The chance that this really is a device that is now been
> removed from the system is almost impossible to happen, but to be safe,
> let's print out the debugging message based on the acpi root device
> which we do have a valid reference to at the moment.

This code was added by 497fb54f578e ("ACPI / PCI: Fix NULL pointer
dereference in acpi_get_pci_dev() (rev. 2)").  Not sure if it's worth
a Fixes: tag.

acpi_get_pci_dev() is used by only five callers, three of which are
video/backlight related.  I'm always skeptical of one-off interfaces
like this, but I don't know enough to propose any refactoring or other
alternatives.

I'll leave this for Rafael, but if I were applying I would silently
touch up the subject to match convention:

  PCI/ACPI: Do not reference PCI device after it has been released

> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-pci@vger.kernel.org
> Cc: linux-acpi@vger.kernel.org
> Reported-by: whitehat002 <hackyzh002@gmail.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/acpi/pci_root.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> index 6f9e75d14808..ecda378dbc09 100644
> --- a/drivers/acpi/pci_root.c
> +++ b/drivers/acpi/pci_root.c
> @@ -303,7 +303,8 @@ struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
>  		 * case pdev->subordinate will be NULL for the parent.
>  		 */
>  		if (!pbus) {
> -			dev_dbg(&pdev->dev, "Not a PCI-to-PCI bridge\n");
> +			dev_dbg(&root->device->dev,
> +				"dev %d, function %d is not a PCI-to-PCI bridge\n", dev, fn);

This should use "%02x.%d" to be consistent with the dev_set_name() in
pci_setup_device().

>  			pdev = NULL;
>  			break;
>  		}
> -- 
> 2.36.0
> 

  reply	other threads:[~2022-04-28 15:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28 14:28 [PATCH] PCI/ACPI: do not reference a pci device after it has been released Greg Kroah-Hartman
2022-04-28 15:58 ` Bjorn Helgaas [this message]
2022-04-28 16:22   ` Greg Kroah-Hartman
2022-04-28 20:15     ` Rafael J. Wysocki
2022-04-28 20:30       ` Rafael J. Wysocki
2022-06-27 15:07         ` Greg Kroah-Hartman
2022-06-27 16:37           ` Rafael J. Wysocki
2022-09-09  7:42             ` Greg Kroah-Hartman
2022-09-09 21:18               ` Rafael J. Wysocki
2022-09-10  5:42                 ` Greg Kroah-Hartman
2022-09-10 13:33                   ` Rafael J. Wysocki
2022-09-10 14:06                     ` Greg Kroah-Hartman

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=20220428155858.GA14614@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hackyzh002@gmail.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=rafael@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;
as well as URLs for NNTP newsgroup(s).