From patchwork Tue Nov 22 10:13:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuan Can X-Patchwork-Id: 13052141 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9DA6C433FE for ; Tue, 22 Nov 2022 10:15:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232446AbiKVKPt (ORCPT ); Tue, 22 Nov 2022 05:15:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232254AbiKVKPs (ORCPT ); Tue, 22 Nov 2022 05:15:48 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 682BA391E3 for ; Tue, 22 Nov 2022 02:15:46 -0800 (PST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NGg9m69rpzHw5h for ; Tue, 22 Nov 2022 18:15:08 +0800 (CST) Received: from huawei.com (10.175.112.208) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 22 Nov 2022 18:15:44 +0800 From: Yuan Can To: , , CC: Subject: [PATCH] PCI: cpqphp: Fix error handling in cpqhpc_init() Date: Tue, 22 Nov 2022 10:13:46 +0000 Message-ID: <20221122101346.80461-1-yuancan@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.208] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The cpqhpc_init() returns the result of pci_register_driver() without checking it, if pci_register_driver() failed, the debugfs created in cpqhp_initialize_debugfs() is not removed, resulting the debugfs of cpqhp can never be created later. Fix by calling cpqhp_shutdown_debugfs() when pci_register_driver() failed. Fixes: 9f3f4681291f ("[PATCH] PCI Hotplug: fix up the sysfs file in the compaq pci hotplug driver") Signed-off-by: Yuan Can --- drivers/pci/hotplug/cpqphp_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c index c94b40e64baf..c47981ef92ea 100644 --- a/drivers/pci/hotplug/cpqphp_core.c +++ b/drivers/pci/hotplug/cpqphp_core.c @@ -1389,6 +1389,8 @@ static int __init cpqhpc_init(void) info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); cpqhp_initialize_debugfs(); result = pci_register_driver(&cpqhpc_driver); + if (result) + cpqhp_shutdown_debugfs(); dbg("pci_register_driver = %d\n", result); return result; }