diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-12-15 07:10:11 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-12-23 08:59:03 -0500 |
commit | 249135d1a2ea3c1719c48d31351413d55d2fdef4 (patch) | |
tree | 19309f9cf047a0c9da189f52fc8e94aeec776e61 /drivers/pnp | |
parent | 319e2e3f63c348a9b66db4667efa73178e18b17d (diff) |
PNPACPI: check return value of pnp_add_device()
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 <dmitry.torokhov@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/pnp')
-rw-r--r-- | drivers/pnp/pnpacpi/core.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 14655a0f0431..4bd4c54ad205 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c | |||
@@ -242,6 +242,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) | |||
242 | struct pnp_dev *dev; | 242 | struct pnp_dev *dev; |
243 | char *pnpid; | 243 | char *pnpid; |
244 | struct acpi_hardware_id *id; | 244 | struct acpi_hardware_id *id; |
245 | int error; | ||
245 | 246 | ||
246 | /* Skip devices that are already bound */ | 247 | /* Skip devices that are already bound */ |
247 | if (device->physical_node_count) | 248 | if (device->physical_node_count) |
@@ -300,10 +301,16 @@ static int __init pnpacpi_add_device(struct acpi_device *device) | |||
300 | /* clear out the damaged flags */ | 301 | /* clear out the damaged flags */ |
301 | if (!dev->active) | 302 | if (!dev->active) |
302 | pnp_init_resources(dev); | 303 | pnp_init_resources(dev); |
303 | pnp_add_device(dev); | 304 | |
305 | error = pnp_add_device(dev); | ||
306 | if (error) { | ||
307 | put_device(&dev->dev); | ||
308 | return error; | ||
309 | } | ||
310 | |||
304 | num++; | 311 | num++; |
305 | 312 | ||
306 | return AE_OK; | 313 | return 0; |
307 | } | 314 | } |
308 | 315 | ||
309 | static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, | 316 | static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, |