Skip to content

Commit

Permalink
PNPACPI: check return value of pnp_add_device()
Browse files Browse the repository at this point in the history
pnp_add_device() may fail so we need to handle errors and avoid leaking
memory. Also, do not use ACPI-specific return codes (AE_OK) but rather
standard one (0).

Signed-off-by: Dmitry Torokhov <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
dtor authored and rafaeljw committed Dec 23, 2013
1 parent 319e2e3 commit 249135d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/pnp/pnpacpi/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
struct pnp_dev *dev;
char *pnpid;
struct acpi_hardware_id *id;
int error;

/* Skip devices that are already bound */
if (device->physical_node_count)
Expand Down Expand Up @@ -300,10 +301,16 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
/* clear out the damaged flags */
if (!dev->active)
pnp_init_resources(dev);
pnp_add_device(dev);

error = pnp_add_device(dev);
if (error) {
put_device(&dev->dev);
return error;
}

num++;

return AE_OK;
return 0;
}

static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
Expand Down

0 comments on commit 249135d

Please sign in to comment.