2023-07-13 04:04:00

by Minjie Du

[permalink] [raw]
Subject: [PATCH v1] dtivers: ntb: fix parameter check in perf_setup_dbgfs()

Make IS_ERR() judge the debugfs_create_dir() function return
in perf_setup_dbgfs().

Signed-off-by: Minjie Du <[email protected]>
---
drivers/ntb/test/ntb_perf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
index 65e1e5cf1..553f1f46b 100644
--- a/drivers/ntb/test/ntb_perf.c
+++ b/drivers/ntb/test/ntb_perf.c
@@ -1355,7 +1355,7 @@ static void perf_setup_dbgfs(struct perf_ctx *perf)
struct pci_dev *pdev = perf->ntb->pdev;

perf->dbgfs_dir = debugfs_create_dir(pci_name(pdev), perf_dbgfs_topdir);
- if (!perf->dbgfs_dir) {
+ if (IS_ERR(perf->dbgfs_dir)) {
dev_warn(&perf->ntb->dev, "DebugFS unsupported\n");
return;
}
--
2.39.0



2023-08-13 15:28:03

by Serge Semin

[permalink] [raw]
Subject: Re: [PATCH v1] dtivers: ntb: fix parameter check in perf_setup_dbgfs()

On Thu, Jul 13, 2023 at 11:47:27AM +0800, Minjie Du wrote:
> Make IS_ERR() judge the debugfs_create_dir() function return
> in perf_setup_dbgfs().

The patch itself is correct for sure:
Reviewed-by: Serge Semin <[email protected]>

But as I already noted in a similar patch submitted for ntb_tool.c:
https://lore.kernel.org/ntb/[email protected]/T/#m78d5823691d2f205d43aaa9e09028674d57296ab

Neither NTB perf, nor NTB tool, nor NTB pong-ping (nor likely NTB MSI
test) drivers make any sense without DebugFS because their
functionality has been developed based on the DebugFS nodes. The
better change would be to just fail the NTB devices probing in these
drivers if DebugFS is unsupported.

-Serge(y)

>
> Signed-off-by: Minjie Du <[email protected]>
> ---
> drivers/ntb/test/ntb_perf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c
> index 65e1e5cf1..553f1f46b 100644
> --- a/drivers/ntb/test/ntb_perf.c
> +++ b/drivers/ntb/test/ntb_perf.c
> @@ -1355,7 +1355,7 @@ static void perf_setup_dbgfs(struct perf_ctx *perf)
> struct pci_dev *pdev = perf->ntb->pdev;
>
> perf->dbgfs_dir = debugfs_create_dir(pci_name(pdev), perf_dbgfs_topdir);
> - if (!perf->dbgfs_dir) {
> + if (IS_ERR(perf->dbgfs_dir)) {
> dev_warn(&perf->ntb->dev, "DebugFS unsupported\n");
> return;
> }
> --
> 2.39.0
>
>