[PATCH -next 2/3] platform/loongarch: laptop: add missing generic_subdriver_exit() in generic_acpi_laptop_init()

From: Yang Yingliang
Date: Sat Oct 08 2022 - 23:41:04 EST


Add missing generic_subdriver_exit() in generic_acpi_laptop_init()
in error path.

Fixes: ee7fa5029de8 ("LoongArch: Add ACPI-based generic laptop driver")
Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
---
drivers/platform/loongarch/loongson-laptop.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/platform/loongarch/loongson-laptop.c b/drivers/platform/loongarch/loongson-laptop.c
index d9f82c3991c0..a9fdfac50f35 100644
--- a/drivers/platform/loongarch/loongson-laptop.c
+++ b/drivers/platform/loongarch/loongson-laptop.c
@@ -582,6 +582,8 @@ static int __init generic_acpi_laptop_init(void)
for (i = 0; i < ARRAY_SIZE(generic_sub_drivers); i++) {
ret = generic_subdriver_init(&generic_sub_drivers[i]);
if (ret < 0) {
+ while (--i >= 0)
+ generic_subdriver_exit(&generic_sub_drivers[i]);
input_free_device(generic_inputdev);
return ret;
}
@@ -589,6 +591,8 @@ static int __init generic_acpi_laptop_init(void)

ret = input_register_device(generic_inputdev);
if (ret < 0) {
+ while (--i >= 0)
+ generic_subdriver_exit(&generic_sub_drivers[i]);
input_free_device(generic_inputdev);
pr_err("Unable to register input device\n");
return ret;
--
2.25.1