diff mbox

PCI: Report pci_pme_active() kmalloc failure

Message ID 20131029231437.19711.61623.stgit@bhelgaas-glaptop.roam.corp.google.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Bjorn Helgaas Oct. 29, 2013, 11:14 p.m. UTC
Previously, if kmalloc() failed, we claimed "PME# enabled" in dmesg,
even though we didn't add the device to the pci_pme_list.  This prints
a more correct warning.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Rafael J. Wysocki Oct. 29, 2013, 11:32 p.m. UTC | #1
On Tuesday, October 29, 2013 05:14:38 PM Bjorn Helgaas wrote:
> Previously, if kmalloc() failed, we claimed "PME# enabled" in dmesg,
> even though we didn't add the device to the pci_pme_list.  This prints
> a more correct warning.
> 
> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  drivers/pci/pci.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index ad7fc72..36cc8d5 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -1638,8 +1638,10 @@ void pci_pme_active(struct pci_dev *dev, bool enable)
>  		if (enable) {
>  			pme_dev = kmalloc(sizeof(struct pci_pme_device),
>  					  GFP_KERNEL);
> -			if (!pme_dev)
> -				goto out;
> +			if (!pme_dev) {
> +				dev_warn(&dev->dev, "can't enable PME#\n");
> +				return;
> +			}
>  			pme_dev->dev = dev;
>  			mutex_lock(&pci_pme_list_mutex);
>  			list_add(&pme_dev->list, &pci_pme_list);
> @@ -1660,7 +1662,6 @@ void pci_pme_active(struct pci_dev *dev, bool enable)
>  		}
>  	}
>  
> -out:
>  	dev_dbg(&dev->dev, "PME# %s\n", enable ? "enabled" : "disabled");
>  }
>  
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index ad7fc72..36cc8d5 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1638,8 +1638,10 @@  void pci_pme_active(struct pci_dev *dev, bool enable)
 		if (enable) {
 			pme_dev = kmalloc(sizeof(struct pci_pme_device),
 					  GFP_KERNEL);
-			if (!pme_dev)
-				goto out;
+			if (!pme_dev) {
+				dev_warn(&dev->dev, "can't enable PME#\n");
+				return;
+			}
 			pme_dev->dev = dev;
 			mutex_lock(&pci_pme_list_mutex);
 			list_add(&pme_dev->list, &pci_pme_list);
@@ -1660,7 +1662,6 @@  void pci_pme_active(struct pci_dev *dev, bool enable)
 		}
 	}
 
-out:
 	dev_dbg(&dev->dev, "PME# %s\n", enable ? "enabled" : "disabled");
 }