[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241023080921.326-2-thunder.leizhen@huawei.com>
Date: Wed, 23 Oct 2024 16:09:20 +0800
From: Zhen Lei <thunder.leizhen@...wei.com>
To: Rasesh Mody <rmody@...vell.com>, Sudarsana Kalluru <skalluru@...vell.com>,
<GR-Linux-NIC-Dev@...vell.com>, Andrew Lunn <andrew+netdev@...n.ch>, "David S
. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub
Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
<netdev@...r.kernel.org>
CC: Zhen Lei <thunder.leizhen@...wei.com>
Subject: [PATCH 1/2] bna: Fix return value check for debugfs create APIs
Fix the incorrect return value check for debugfs_create_dir() and
debugfs_create_file(), which returns ERR_PTR(-ERROR) instead of NULL
when it fails.
Commit 4ad23d2368cc ("bna: Remove error checking for
debugfs_create_dir()") allows the program to continue execution if the
creation of bnad->port_debugfs_root fails, which causes the atomic count
bna_debugfs_port_count to be unbalanced. The corresponding error check
need to be added back.
Fixes: 4ad23d2368cc ("bna: Remove error checking for debugfs_create_dir()")
Fixes: 7afc5dbde091 ("bna: Add debugfs interface.")
Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
---
drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
index 97291bfbeea589e..ad0b29391f990f3 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
@@ -493,25 +493,29 @@ void
bnad_debugfs_init(struct bnad *bnad)
{
const struct bnad_debugfs_entry *file;
+ struct dentry *de;
char name[64];
int i;
/* Setup the BNA debugfs root directory*/
if (!bna_debugfs_root) {
- bna_debugfs_root = debugfs_create_dir("bna", NULL);
+ de = debugfs_create_dir("bna", NULL);
atomic_set(&bna_debugfs_port_count, 0);
- if (!bna_debugfs_root) {
+ if (IS_ERR(de)) {
netdev_warn(bnad->netdev,
"debugfs root dir creation failed\n");
return;
}
+ bna_debugfs_root = de;
}
/* Setup the pci_dev debugfs directory for the port */
snprintf(name, sizeof(name), "pci_dev:%s", pci_name(bnad->pcidev));
if (!bnad->port_debugfs_root) {
- bnad->port_debugfs_root =
- debugfs_create_dir(name, bna_debugfs_root);
+ de = debugfs_create_dir(name, bna_debugfs_root);
+ if (IS_ERR(de))
+ return;
+ bnad->port_debugfs_root = de;
atomic_inc(&bna_debugfs_port_count);
@@ -523,7 +527,7 @@ bnad_debugfs_init(struct bnad *bnad)
bnad->port_debugfs_root,
bnad,
file->fops);
- if (!bnad->bnad_dentry_files[i]) {
+ if (IS_ERR(bnad->bnad_dentry_files[i])) {
netdev_warn(bnad->netdev,
"create %s entry failed\n",
file->name);
--
2.34.1
Powered by blists - more mailing lists