ACPI / container: Fix error code path in container_device_attach()

To avoid leaking memory on errors from device_register(), do a
put_device() on the device object in question in the error code
path of container_device_attach().

Fixes: caa73ea158 (ACPI / hotplug / driver core: Handle containers in a special way)
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
This commit is contained in:
Rafael J. Wysocki 2014-02-12 00:52:49 +01:00
Родитель 8fcfb99c8e
Коммит 0f6aa09e40
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -79,9 +79,10 @@ static int container_device_attach(struct acpi_device *adev,
ACPI_COMPANION_SET(dev, adev);
dev->release = acpi_container_release;
ret = device_register(dev);
if (ret)
if (ret) {
put_device(dev);
return ret;
}
adev->driver_data = dev;
return 1;
}