Commit 786f18c666d7202a86a8aa42a98783b115fe8739

Authored by Dmitry Torokhov
Committed by Len Brown
1 parent b4bd8c6643

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>

Showing 1 changed file with 3 additions and 6 deletions Side-by-side Diff

drivers/acpi/power.c
... ... @@ -216,10 +216,8 @@
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 220  
222   -
223 221 result = acpi_power_get_context(handle, &resource);
224 222 if (result)
225 223 return result;
226 224  
... ... @@ -230,13 +228,13 @@
230 228 if (resource->references) {
231 229 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
232 230 "Resource [%s] is still in use, dereferencing\n",
233   - device->pnp.bus_id));
  231 + resource->device->pnp.bus_id));
234 232 return 0;
235 233 }
236 234  
237 235 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) {
238 236 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n",
239   - device->pnp.bus_id));
  237 + resource->device->pnp.bus_id));
240 238 return 0;
241 239 }
242 240  
... ... @@ -251,8 +249,7 @@
251 249 return -ENOEXEC;
252 250  
253 251 /* Update the power resource's _device_ power state */
254   - device = resource->device;
255   - device->power.state = ACPI_STATE_D3;
  252 + resource->device->power.state = ACPI_STATE_D3;
256 253  
257 254 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n",
258 255 resource->name));