1 From e2fd973c6bc2a6bc51dae88b102ff1b172274fe2 Mon Sep 17 00:00:00 2001
2 From: Junxiao Chang <junxiao.chang@intel.com>
3 Date: Mon, 8 Apr 2019 17:40:22 +0800
4 Subject: platform/x86: intel_pmc_ipc: adding error handling
6 [ Upstream commit e61985d0550df8c2078310202aaad9b41049c36c ]
8 If punit or telemetry device initialization fails, pmc driver should
9 unregister and return failure.
11 This change is to fix a kernel panic when removing kernel module
14 Fixes: 48c1917088ba ("platform:x86: Add Intel telemetry platform device")
15 Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>
16 Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
17 Signed-off-by: Sasha Levin <sashal@kernel.org>
19 drivers/platform/x86/intel_pmc_ipc.c | 6 +++++-
20 1 file changed, 5 insertions(+), 1 deletion(-)
22 diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
23 index 0bf51d574fa9..f2b9dd82128f 100644
24 --- a/drivers/platform/x86/intel_pmc_ipc.c
25 +++ b/drivers/platform/x86/intel_pmc_ipc.c
26 @@ -620,13 +620,17 @@ static int ipc_create_pmc_devices(void)
28 dev_err(ipcdev.dev, "Failed to add punit platform device\n");
29 platform_device_unregister(ipcdev.tco_dev);
33 if (!ipcdev.telem_res_inval) {
34 ret = ipc_create_telemetry_device();
38 "Failed to add telemetry platform device\n");
39 + platform_device_unregister(ipcdev.punit_dev);
40 + platform_device_unregister(ipcdev.tco_dev);