Commit 2f663539 authored by Kefeng Wang's avatar Kefeng Wang Committed by Corey Minyard

ipmi_si: fix unexpected driver unregister warning

If ipmi_si_platform_init()->platform_driver_register() fails,
platform_driver_unregister() called unconditionally will trigger
following warning,

ipmi_platform: Unable to register driver: -12
------------[ cut here ]------------
Unexpected driver unregister!
WARNING: CPU: 1 PID: 7210 at drivers/base/driver.c:193 driver_unregister+0x60/0x70 drivers/base/driver.c:193

Fix it by adding platform_registered variable, only unregister platform
driver when it is already successfully registered.
Reported-by: default avatarHulk Robot <hulkci@huawei.com>
Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Message-Id: <20190517101245.4341-1-wangkefeng.wang@huawei.com>
Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
parent a188339c
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "ipmi_si.h" #include "ipmi_si.h"
#include "ipmi_dmi.h" #include "ipmi_dmi.h"
static bool platform_registered;
static bool si_tryplatform = true; static bool si_tryplatform = true;
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
static bool si_tryacpi = true; static bool si_tryacpi = true;
...@@ -469,9 +470,12 @@ void ipmi_si_platform_init(void) ...@@ -469,9 +470,12 @@ void ipmi_si_platform_init(void)
int rv = platform_driver_register(&ipmi_platform_driver); int rv = platform_driver_register(&ipmi_platform_driver);
if (rv) if (rv)
pr_err("Unable to register driver: %d\n", rv); pr_err("Unable to register driver: %d\n", rv);
else
platform_registered = true;
} }
void ipmi_si_platform_shutdown(void) void ipmi_si_platform_shutdown(void)
{ {
platform_driver_unregister(&ipmi_platform_driver); if (platform_registered)
platform_driver_unregister(&ipmi_platform_driver);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment