Re: 回复: [PATCH v2] ntb:Fix an NULL vs IS_ERR() bug for debugfs_create_dir() in tool_setup_dbgfs()

From: Dan Carpenter
Date: Thu Jul 13 2023 - 02:00:36 EST


On Thu, Jul 13, 2023 at 02:13:32AM +0000, 王明-软件底层技术部 wrote:
> Hi dan carpenter
> You mean that this modification is correct, but there is no need to do
> so, is that the understanding?

No, this patch is wrong. Possibly harmless, possibly harmful but either
way it is wrong. The correct way is:

diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c
index eeeb4b1c97d2..e0acc11d29ba 100644
--- a/drivers/ntb/test/ntb_tool.c
+++ b/drivers/ntb/test/ntb_tool.c
@@ -1495,8 +1495,6 @@ static void tool_setup_dbgfs(struct tool_ctx *tc)

tc->dbgfs_dir = debugfs_create_dir(dev_name(&tc->ntb->dev),
tool_dbgfs_topdir);
- if (!tc->dbgfs_dir)
- return;

debugfs_create_file("port", 0600, tc->dbgfs_dir,
tc, &tool_port_fops);