summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/device_pm.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-06-29 15:03:38 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-06-29 15:03:38 +0200
commitd5ba5b141dae17155d12b897f2eedeaf6800db7c (patch)
tree6b5395d91b852562cebedfeebc4726b45cd70e7f /drivers/acpi/device_pm.c
parent996e2569dab534089b095da86e5d01d9d954279e (diff)
parent9b5c7a5a977a330ffaf83c4d383ba247c74c800f (diff)
downloadlinux-d5ba5b141dae17155d12b897f2eedeaf6800db7c.tar.gz
linux-d5ba5b141dae17155d12b897f2eedeaf6800db7c.tar.bz2
linux-d5ba5b141dae17155d12b897f2eedeaf6800db7c.zip
Merge branch 'acpi-pm'
* acpi-pm: ACPI / PM: Fix possible NULL pointer deref in acpi_pm_device_sleep_state()
Diffstat (limited to 'drivers/acpi/device_pm.c')
-rw-r--r--drivers/acpi/device_pm.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 67624d4d5aef..e9e8bb24785b 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -541,7 +541,7 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
{
acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
struct acpi_device *adev;
- int ret, d_max;
+ int ret, d_min, d_max;
if (d_max_in < ACPI_STATE_D0 || d_max_in > ACPI_STATE_D3_COLD)
return -EINVAL;
@@ -560,19 +560,23 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
}
ret = acpi_dev_pm_get_state(dev, adev, acpi_target_system_state(),
- d_min_p, &d_max);
+ &d_min, &d_max);
if (ret)
return ret;
- if (d_max_in < *d_min_p)
+ if (d_max_in < d_min)
return -EINVAL;
if (d_max > d_max_in) {
- for (d_max = d_max_in; d_max > *d_min_p; d_max--) {
+ for (d_max = d_max_in; d_max > d_min; d_max--) {
if (adev->power.states[d_max].flags.valid)
break;
}
}
+
+ if (d_min_p)
+ *d_min_p = d_min;
+
return d_max;
}
EXPORT_SYMBOL(acpi_pm_device_sleep_state);