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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 166A9C433FE for ; Tue, 22 Nov 2022 20:05:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233984AbiKVUF4 (ORCPT ); Tue, 22 Nov 2022 15:05:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232491AbiKVUFy (ORCPT ); Tue, 22 Nov 2022 15:05:54 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36F2687555 for ; Tue, 22 Nov 2022 12:05:54 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CFF14617E3 for ; Tue, 22 Nov 2022 20:05:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15AEDC433C1; Tue, 22 Nov 2022 20:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669147553; bh=bic0W/Yz7oujIlwrDxUCxfYXaKqHGMrhHAtNLxnCiLs=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=YPRCJzT/Uu0169iRloByfuM7zEX50iI2E8r/Iv5KtP4anmGuz5iyWtJK1kO0L6F9w ngd2slPSFaF/wLvvnDGkZ/3r5vPUD/bbV2CjnmgiwgNKAyoiogBmECkdATm5hdgRqV FiVf8GLfJH21R/4gTBryJcuIR5FojU4TVKmY97Mbwptt8bQ2AoSO2RwE8hdec11gxz Bt2mdwcAgH3h2QfOANUfHgsc1bSxTBLsKO53sjHZev9JcE8+DnV/17QhhmsijrMsPJ YB0jZn5h8Pph3vg+uMo8XOPXmj7sAGoJoUgDNHTyCqhLrQRJTwnGAvtdY+B0C5RCWF ahdc1dvPjZgwA== Date: Tue, 22 Nov 2022 14:05:51 -0600 From: Bjorn Helgaas To: Yuan Can Cc: bhelgaas@google.com, gregkh@suse.de, linux-pci@vger.kernel.org Subject: Re: [PATCH] PCI: cpqphp: Fix error handling in cpqhpc_init() Message-ID: <20221122200551.GA212321@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221122101346.80461-1-yuancan@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Tue, Nov 22, 2022 at 10:13:46AM +0000, Yuan Can wrote: > 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. Add a blank line between paragraphs. > 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(); Is there some reason cpqhp_initialize_debugfs() needs to be called before pci_register_driver()? In other words, could we do this instead? result = pci_register_driver(&cpqhpc_driver); if (result) return result; cpqhp_initialize_debugfs(); return 0; I assume this was found by code inspection? I've never heard of anybody actually using this driver :) > dbg("pci_register_driver = %d\n", result); > return result; > } > -- > 2.17.1 >