From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C554C31E45 for ; Thu, 13 Jun 2019 16:14:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 174BF20665 for ; Thu, 13 Jun 2019 16:14:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560442444; bh=fMyvAqWhEet+kqapguNtwwh+UxadFguoNUCNXp7W0XU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Q4YhlUh1ZgcxGObKUjIplDfJ3HBnK5nYAod+mfhWnkxmLymoEZWo+LkV5Ebs4MUXK DetPXm1mXHfB9f37es/BklxwMYtydNw1agQkRwWlFrVyMYmeLJALQsupihlb9lKF39 nKZauZ/tlr2lRUIE2T8fotCwQkmbjjrEeDrcI4Uw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391789AbfFMQOD (ORCPT ); Thu, 13 Jun 2019 12:14:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:59672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731198AbfFMImb (ORCPT ); Thu, 13 Jun 2019 04:42:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E1B392063F; Thu, 13 Jun 2019 08:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560415350; bh=fMyvAqWhEet+kqapguNtwwh+UxadFguoNUCNXp7W0XU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NHAI3qjktJRQcY7k1QnAxnryYdizZL59blaGKDFd49fk2WE/rLxRjkZGzslpt9NJS SoUntoifRzR9JG/laAFrxfxKF6l7p38SmIIH+icOFQdySBofmI/WHUQIK8RTMnqeSZ uDOIUWK8tTKtlMsicysxV2Lv0c3TWONxKQYHTNkY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Junxiao Chang , Andy Shevchenko , Sasha Levin Subject: [PATCH 4.19 093/118] platform/x86: intel_pmc_ipc: adding error handling Date: Thu, 13 Jun 2019 10:33:51 +0200 Message-Id: <20190613075649.300207286@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190613075643.642092651@linuxfoundation.org> References: <20190613075643.642092651@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit e61985d0550df8c2078310202aaad9b41049c36c ] 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 Signed-off-by: Andy Shevchenko Signed-off-by: Sasha Levin --- 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 e7edc8c63936..4ad9d127f2f5 100644 --- a/drivers/platform/x86/intel_pmc_ipc.c +++ b/drivers/platform/x86/intel_pmc_ipc.c @@ -776,13 +776,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.20.1