From: Hans de Goede <hdegoede@redhat.com>
To: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
Len Brown <lenb@kernel.org>, Sebastian Reichel <sre@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Lukas Wunner <lukas@wunner.de>,
Robert Moore <robert.moore@intel.com>,
linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org
Subject: [PATCH v4 2/4] ACPI: battery: Fix acpi_battery_exit on acpi_battery_init_async errors
Date: Sat, 8 Apr 2017 23:48:28 +0200 [thread overview]
Message-ID: <20170408214830.17650-2-hdegoede@redhat.com> (raw)
In-Reply-To: <20170408214830.17650-1-hdegoede@redhat.com>
The acpi_lock_battery_dir() / acpi_bus_register_driver() calls in
acpi_battery_init_async() may fail. Check that they succeeded before
undoing them.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/acpi/battery.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 4ef1e46..b35fca4 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -67,6 +67,7 @@ MODULE_DESCRIPTION("ACPI Battery Driver");
MODULE_LICENSE("GPL");
static async_cookie_t async_cookie;
+static bool battery_driver_registered;
static int battery_bix_broken_package;
static int battery_notification_delay_ms;
static unsigned int cache_time = 1000;
@@ -1329,6 +1330,7 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
if (result < 0)
acpi_unlock_battery_dir(acpi_battery_dir);
#endif
+ battery_driver_registered = (result == 0);
}
static int __init acpi_battery_init(void)
@@ -1343,9 +1345,11 @@ static int __init acpi_battery_init(void)
static void __exit acpi_battery_exit(void)
{
async_synchronize_cookie(async_cookie + 1);
- acpi_bus_unregister_driver(&acpi_battery_driver);
+ if (battery_driver_registered)
+ acpi_bus_unregister_driver(&acpi_battery_driver);
#ifdef CONFIG_ACPI_PROCFS_POWER
- acpi_unlock_battery_dir(acpi_battery_dir);
+ if (acpi_battery_dir)
+ acpi_unlock_battery_dir(acpi_battery_dir);
#endif
}
--
2.9.3
next prev parent reply other threads:[~2017-04-08 21:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-08 21:48 [PATCH v4 1/4] ACPI: utils: Add new acpi_dev_present helper Hans de Goede
2017-04-08 21:48 ` Hans de Goede [this message]
2017-04-08 21:48 ` [PATCH v4 3/4] ACPI: battery: Add a blacklist with PMIC ACPI HIDs with a native battery driver Hans de Goede
2017-04-08 21:48 ` [PATCH v4 4/4] ACPI: ac: Add a blacklist with PMIC ACPI HIDs with a native charger driver Hans de Goede
2017-04-09 8:16 ` [PATCH v4 1/4] ACPI: utils: Add new acpi_dev_present helper Lukas Wunner
2017-04-10 18:24 ` Hans de Goede
2017-04-10 7:23 ` Hans de Goede
2017-04-10 18:14 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170408214830.17650-2-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=rjw@rjwysocki.net \
--cc=robert.moore@intel.com \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).