ntb.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Yuan Can <yuancan@huawei.com>,
	jdmason@kudzu.us, allenbh@gmail.com, ntb@lists.linux.dev
Subject: Re: [PATCH] ntb: intel: Fix error handling in intel_ntb_pci_driver_init()
Date: Mon, 7 Nov 2022 07:28:58 -0800	[thread overview]
Message-ID: <1bbf45ff-38bd-989c-d938-f7ce094b6197@intel.com> (raw)
In-Reply-To: <20221105094322.106585-1-yuancan@huawei.com>



On 11/5/2022 2:43 AM, Yuan Can wrote:
> A problem about ntb_hw_intel create debugfs failed is triggered with the
> following log given:
> 
>   [  273.112733] Intel(R) PCI-E Non-Transparent Bridge Driver 2.0
>   [  273.115342] debugfs: Directory 'ntb_hw_intel' with parent '/' already present!
> 
> The reason is that intel_ntb_pci_driver_init() returns
> pci_register_driver() directly without checking its return value, if
> pci_register_driver() failed, it returns without destroy the newly created
> debugfs, resulting the debugfs of ntb_hw_intel can never be created later.
> 
>   intel_ntb_pci_driver_init()
>     debugfs_create_dir() # create debugfs directory
>     pci_register_driver()
>       driver_register()
>         bus_add_driver()
>           priv = kzalloc(...) # OOM happened
>     # return without destroy debugfs directory
> 
> Fix by removing debugfs when pci_register_driver() returns error.
> 
> Fixes: e26a5843f7f5 ("NTB: Split ntb_hw_intel and ntb_transport drivers")
> Signed-off-by: Yuan Can <yuancan@huawei.com>

Acked-by: Dave Jiang <dave.jiang@intel.com>

> ---
>   drivers/ntb/hw/intel/ntb_hw_gen1.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ntb/hw/intel/ntb_hw_gen1.c b/drivers/ntb/hw/intel/ntb_hw_gen1.c
> index 84772013812b..60a4ebc7bf35 100644
> --- a/drivers/ntb/hw/intel/ntb_hw_gen1.c
> +++ b/drivers/ntb/hw/intel/ntb_hw_gen1.c
> @@ -2064,12 +2064,17 @@ static struct pci_driver intel_ntb_pci_driver = {
>   
>   static int __init intel_ntb_pci_driver_init(void)
>   {
> +	int ret;
>   	pr_info("%s %s\n", NTB_DESC, NTB_VER);
>   
>   	if (debugfs_initialized())
>   		debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
>   
> -	return pci_register_driver(&intel_ntb_pci_driver);
> +	ret = pci_register_driver(&intel_ntb_pci_driver);
> +	if (ret)
> +		debugfs_remove_recursive(debugfs_dir);
> +
> +	return ret;
>   }
>   module_init(intel_ntb_pci_driver_init);
>   

      reply	other threads:[~2022-11-07 15:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-05  9:43 [PATCH] ntb: intel: Fix error handling in intel_ntb_pci_driver_init() Yuan Can
2022-11-07 15:28 ` Dave Jiang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1bbf45ff-38bd-989c-d938-f7ce094b6197@intel.com \
    --to=dave.jiang@intel.com \
    --cc=allenbh@gmail.com \
    --cc=jdmason@kudzu.us \
    --cc=ntb@lists.linux.dev \
    --cc=yuancan@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).