diff mbox series

PCI/PM: Call .bridge_d3() hook only if non-NULL

Message ID 20200415000635.144283-1-helgaas@kernel.org
State New
Headers show
Series PCI/PM: Call .bridge_d3() hook only if non-NULL | expand

Commit Message

Bjorn Helgaas April 15, 2020, 12:06 a.m. UTC
From: Bjorn Helgaas <bhelgaas@google.com>

26ad34d510a8 ("PCI / ACPI: Whitelist D3 for more PCIe hotplug ports") added
the struct pci_platform_pm_ops.bridge_d3() function pointer and
platform_pci_bridge_d3() to use it.

The .bridge_d3() op is implemented by acpi_pci_platform_pm, but not by
mid_pci_platform_pm.  We don't expect platform_pci_bridge_d3() to be called
on Intel MID platforms, but nothing in the code itself would prevent that.

Check the .bridge_d3() pointer for NULL before calling it.

Fixes: 26ad34d510a8 ("PCI / ACPI: Whitelist D3 for more PCIe hotplug ports")
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/pci/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Mika Westerberg April 15, 2020, 7:29 a.m. UTC | #1
On Tue, Apr 14, 2020 at 07:06:35PM -0500, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <bhelgaas@google.com>
> 
> 26ad34d510a8 ("PCI / ACPI: Whitelist D3 for more PCIe hotplug ports") added
> the struct pci_platform_pm_ops.bridge_d3() function pointer and
> platform_pci_bridge_d3() to use it.
> 
> The .bridge_d3() op is implemented by acpi_pci_platform_pm, but not by
> mid_pci_platform_pm.  We don't expect platform_pci_bridge_d3() to be called
> on Intel MID platforms, but nothing in the code itself would prevent that.
> 
> Check the .bridge_d3() pointer for NULL before calling it.
> 
> Fixes: 26ad34d510a8 ("PCI / ACPI: Whitelist D3 for more PCIe hotplug ports")
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Thanks!
Bjorn Helgaas April 24, 2020, 7:34 p.m. UTC | #2
On Tue, Apr 14, 2020 at 07:06:35PM -0500, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <bhelgaas@google.com>
> 
> 26ad34d510a8 ("PCI / ACPI: Whitelist D3 for more PCIe hotplug ports") added
> the struct pci_platform_pm_ops.bridge_d3() function pointer and
> platform_pci_bridge_d3() to use it.
> 
> The .bridge_d3() op is implemented by acpi_pci_platform_pm, but not by
> mid_pci_platform_pm.  We don't expect platform_pci_bridge_d3() to be called
> on Intel MID platforms, but nothing in the code itself would prevent that.
> 
> Check the .bridge_d3() pointer for NULL before calling it.
> 
> Fixes: 26ad34d510a8 ("PCI / ACPI: Whitelist D3 for more PCIe hotplug ports")
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>

Applied with Mika's reviewed-by to pci/pm for v5.8.

> ---
>  drivers/pci/pci.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 595fcf59843f..dfa7ec008963 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -868,7 +868,9 @@ static inline bool platform_pci_need_resume(struct pci_dev *dev)
>  
>  static inline bool platform_pci_bridge_d3(struct pci_dev *dev)
>  {
> -	return pci_platform_pm ? pci_platform_pm->bridge_d3(dev) : false;
> +	if (pci_platform_pm && pci_platform_pm->bridge_d3)
> +		return pci_platform_pm->bridge_d3(dev);
> +	return false;
>  }
>  
>  /**
> -- 
> 2.26.0.110.g2183baf09c-goog
>
diff mbox series

Patch

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 595fcf59843f..dfa7ec008963 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -868,7 +868,9 @@  static inline bool platform_pci_need_resume(struct pci_dev *dev)
 
 static inline bool platform_pci_bridge_d3(struct pci_dev *dev)
 {
-	return pci_platform_pm ? pci_platform_pm->bridge_d3(dev) : false;
+	if (pci_platform_pm && pci_platform_pm->bridge_d3)
+		return pci_platform_pm->bridge_d3(dev);
+	return false;
 }
 
 /**