2023-05-12 13:12:38

by Ivan Orlov

[permalink] [raw]
Subject: [PATCH] nbd: Fix debugfs_create_dir error checking

The debugfs_create_dir function returns ERR_PTR in case of error, and the
only correct way to check if an error occurred is 'IS_ERR' inline function.
This patch will replace the null-comparison with IS_ERR.

Signed-off-by: Ivan Orlov <[email protected]>
---
drivers/block/nbd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 9c35c958f2c8..65ecde3e2a5b 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1666,7 +1666,7 @@ static int nbd_dev_dbg_init(struct nbd_device *nbd)
return -EIO;

dir = debugfs_create_dir(nbd_name(nbd), nbd_dbg_dir);
- if (!dir) {
+ if (IS_ERR(dir)) {
dev_err(nbd_to_dev(nbd), "Failed to create debugfs dir for '%s'\n",
nbd_name(nbd));
return -EIO;
@@ -1692,7 +1692,7 @@ static int nbd_dbg_init(void)
struct dentry *dbg_dir;

dbg_dir = debugfs_create_dir("nbd", NULL);
- if (!dbg_dir)
+ if (IS_ERR(dbg_dir))
return -EIO;

nbd_dbg_dir = dbg_dir;
--
2.34.1



2023-05-12 15:17:20

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH] nbd: Fix debugfs_create_dir error checking


On Fri, 12 May 2023 17:05:32 +0400, Ivan Orlov wrote:
> The debugfs_create_dir function returns ERR_PTR in case of error, and the
> only correct way to check if an error occurred is 'IS_ERR' inline function.
> This patch will replace the null-comparison with IS_ERR.
>
>

Applied, thanks!

[1/1] nbd: Fix debugfs_create_dir error checking
commit: 4913cfcf014c95f0437db2df1734472fd3e15098

Best regards,
--
Jens Axboe