Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI: fix potential OOPS in power driver with CONFIG_ACPI_DEBUG

device was set to null and used before set in a debug printk

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Len Brown <len.brown@intel.com>

authored by

Dmitry Torokhov and committed by
Len Brown
786f18c6 b4bd8c66

+3 -6
+3 -6
drivers/acpi/power.c
··· 216 216 { 217 217 int result = 0; 218 218 acpi_status status = AE_OK; 219 - struct acpi_device *device = NULL; 220 219 struct acpi_power_resource *resource = NULL; 221 - 222 220 223 221 result = acpi_power_get_context(handle, &resource); 224 222 if (result) ··· 228 230 if (resource->references) { 229 231 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 230 232 "Resource [%s] is still in use, dereferencing\n", 231 - device->pnp.bus_id)); 233 + resource->device->pnp.bus_id)); 232 234 return 0; 233 235 } 234 236 235 237 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) { 236 238 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n", 237 - device->pnp.bus_id)); 239 + resource->device->pnp.bus_id)); 238 240 return 0; 239 241 } 240 242 ··· 249 251 return -ENOEXEC; 250 252 251 253 /* Update the power resource's _device_ power state */ 252 - device = resource->device; 253 - device->power.state = ACPI_STATE_D3; 254 + resource->device->power.state = ACPI_STATE_D3; 254 255 255 256 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", 256 257 resource->name));