Re: [PATCH] PCI/ACPI: do not reference a pci device after it has been released

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 28, 2022 at 10:58:58AM -0500, Bjorn Helgaas wrote:
> 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.

Can't hurt, I'll add it for the v2 based on this review.

> 
> 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

Much simpler, thanks.

> 
> > Cc: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
> > Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
> > Cc: Len Brown <lenb@xxxxxxxxxx>
> > Cc: linux-pci@xxxxxxxxxxxxxxx
> > Cc: linux-acpi@xxxxxxxxxxxxxxx
> > Reported-by: whitehat002 <hackyzh002@xxxxxxxxx>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> > ---
> >  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().

Ah, missed that, will change it and send out a new version tomorrow.

thanks for the quick review.

greg k-h



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux