diff mbox series

[v2] platform/x86: intel_pmc_ipc: adding error handling

Message ID 1554716422-7099-1-git-send-email-junxiao.chang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Andy Shevchenko
Headers show
Series [v2] platform/x86: intel_pmc_ipc: adding error handling | expand

Commit Message

Chang, Junxiao April 8, 2019, 9:40 a.m. UTC
From: Junxiao Chang <junxiao.chang@intel.com>

If punit or telemetry device initialization fails, pmc driver should
unregister and return failure.

This change is to fix a kernel panic when removing kernel module
intel_pmc_ipc.

Fixes: 48c1917088ba ("platform:x86: Add Intel telemetry platform device")
Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>
---
 drivers/platform/x86/intel_pmc_ipc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Andy Shevchenko April 8, 2019, 5:59 p.m. UTC | #1
On Mon, Apr 8, 2019 at 12:44 PM <junxiao.chang@intel.com> wrote:
>
> From: Junxiao Chang <junxiao.chang@intel.com>
>
> If punit or telemetry device initialization fails, pmc driver should
> unregister and return failure.
>
> This change is to fix a kernel panic when removing kernel module
> intel_pmc_ipc.
>

Pushed to my review and testing queue, thanks!

> Fixes: 48c1917088ba ("platform:x86: Add Intel telemetry platform device")
> Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>
> ---
>  drivers/platform/x86/intel_pmc_ipc.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
> index 7964ba2..d37cbd1 100644
> --- a/drivers/platform/x86/intel_pmc_ipc.c
> +++ b/drivers/platform/x86/intel_pmc_ipc.c
> @@ -771,13 +771,17 @@ static int ipc_create_pmc_devices(void)
>         if (ret) {
>                 dev_err(ipcdev.dev, "Failed to add punit platform device\n");
>                 platform_device_unregister(ipcdev.tco_dev);
> +               return ret;
>         }
>
>         if (!ipcdev.telem_res_inval) {
>                 ret = ipc_create_telemetry_device();
> -               if (ret)
> +               if (ret) {
>                         dev_warn(ipcdev.dev,
>                                 "Failed to add telemetry platform device\n");
> +                       platform_device_unregister(ipcdev.punit_dev);
> +                       platform_device_unregister(ipcdev.tco_dev);
> +               }
>         }
>
>         return ret;
> --
> 2.7.4
>
diff mbox series

Patch

diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
index 7964ba2..d37cbd1 100644
--- a/drivers/platform/x86/intel_pmc_ipc.c
+++ b/drivers/platform/x86/intel_pmc_ipc.c
@@ -771,13 +771,17 @@  static int ipc_create_pmc_devices(void)
 	if (ret) {
 		dev_err(ipcdev.dev, "Failed to add punit platform device\n");
 		platform_device_unregister(ipcdev.tco_dev);
+		return ret;
 	}
 
 	if (!ipcdev.telem_res_inval) {
 		ret = ipc_create_telemetry_device();
-		if (ret)
+		if (ret) {
 			dev_warn(ipcdev.dev,
 				"Failed to add telemetry platform device\n");
+			platform_device_unregister(ipcdev.punit_dev);
+			platform_device_unregister(ipcdev.tco_dev);
+		}
 	}
 
 	return ret;