mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-02 06:16:41 +07:00
Merge branch 'acpi-pm'
* acpi-pm: ACPI / PM: Fix possible NULL pointer deref in acpi_pm_device_sleep_state()
This commit is contained in:
commit
d5ba5b141d
@ -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);
|
acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
|
||||||
struct acpi_device *adev;
|
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)
|
if (d_max_in < ACPI_STATE_D0 || d_max_in > ACPI_STATE_D3_COLD)
|
||||||
return -EINVAL;
|
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(),
|
ret = acpi_dev_pm_get_state(dev, adev, acpi_target_system_state(),
|
||||||
d_min_p, &d_max);
|
&d_min, &d_max);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (d_max_in < *d_min_p)
|
if (d_max_in < d_min)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (d_max > d_max_in) {
|
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)
|
if (adev->power.states[d_max].flags.valid)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (d_min_p)
|
||||||
|
*d_min_p = d_min;
|
||||||
|
|
||||||
return d_max;
|
return d_max;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(acpi_pm_device_sleep_state);
|
EXPORT_SYMBOL(acpi_pm_device_sleep_state);
|
||||||
|
Loading…
Reference in New Issue
Block a user