[PATCH 1/5] ACPI: battery: check result of register_pm_notifier()

Thomas Weißschuh posted 5 patches 1 year, 5 months ago
[PATCH 1/5] ACPI: battery: check result of register_pm_notifier()
Posted by Thomas Weißschuh 1 year, 5 months ago
This function call can fail, check for that.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 drivers/acpi/battery.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index da3a879d638a..677618eb38bf 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -1235,7 +1235,9 @@ static int acpi_battery_add(struct acpi_device *device)
 		device->status.battery_present ? "present" : "absent");
 
 	battery->pm_nb.notifier_call = battery_notify;
-	register_pm_notifier(&battery->pm_nb);
+	result = register_pm_notifier(&battery->pm_nb);
+	if (result)
+		goto fail;
 
 	device_init_wakeup(&device->dev, 1);
 

-- 
2.46.0