zswap: ignore debugfs_create_dir() return value
Subsystems (2)
PATCH 1/1 zswap: ignore debugfs_create_dir() return value
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
--- mm/zswap.c | 2 -- 1 file changed, 2 deletions(-)
mm/zswap.c +0 -2
@@ -1262,8 +1262,6 @@ static int __init zswap_debugfs_init(void)return -ENODEV ; zswap_debugfs_root =debugfs_create_dir ("zswap" ,NULL ); -if (!zswap_debugfs_root) -return -ENOMEM ;debugfs_create_u64 ("pool_limit_hit" ,0444 , zswap_debugfs_root, &zswap_pool_limit_hit);
Signature · 1 line
2.20.1
Quoted 18 lines · Greg Kroah-Hartman
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
Cc Seth Jennings <[email protected]>Cc Dan Streetman <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- mm/zswap.c | 2 -- 1 file changed, 2 deletions(-)mm/zswap.c +0
-0
mm/zswap.c static int __init zswap_debugfs_init(void) · line 1267
Quoted 8 lines
mm/zswap.c +0
-2@@ -1262,8 +1262,6 @@ static int __init zswap_debugfs_init(void)return -ENODEV ; zswap_debugfs_root =debugfs_create_dir ("zswap" ,NULL ); -if (!zswap_debugfs_root) -return -ENOMEM ;debugfs_create_u64 ("pool_limit_hit" ,0444 , zswap_debugfs_root, &zswap_pool_limit_hit);
wait, so if i'm reading the code right, in the case where debugfs_create_dir() returns NULL, that will then be passed along to debugfs_create_u64() as its parent directory - and the debugfs nodes will then get created in the root debugfs directory. That's not what we want to happen...
Quoted 3 lines
--
2.20.1
Quoted 26 lines · Dan Streetman
Quoted 24 lines · Greg Kroah-Hartman
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
Cc Seth Jennings <[email protected]>Cc Dan Streetman <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- mm/zswap.c | 2 -- 1 file changed, 2 deletions(-)mm/zswap.c +0
-2@@ -1262,8 +1262,6 @@ static int __init zswap_debugfs_init(void)return -ENODEV ; zswap_debugfs_root =debugfs_create_dir ("zswap" ,NULL ); -if (!zswap_debugfs_root) -return -ENOMEM ;
Quoted 8 lines
mm/zswap.c static int __init zswap_debugfs_init(void) · line 1267
Quoted 2 lines
mm/zswap.c +0
-0debugfs_create_u64 ("pool_limit_hit" ,0444 , zswap_debugfs_root, &zswap_pool_limit_hit);wait, so if i'm reading the code right, in the case where
debugfs_create_dir()returns NULL, that will then be passed along todebugfs_create_u64()as its parent directory - and the debugfs nodes will then get created in the root debugfs directory. That's not what we want to happen...
True, but that is such a rare thing to ever happen (hint, you have to be out of memory), that it's not really a bad thing. But, you are not the first to mention this, which is why this patch is on its way to Linus for 5.0-final:
https://lore.kernel.org/lkml/[email protected]/
thanks,
greg k-h
Dan Streetman
Acked-byQuoted 37 lines · Greg Kroah-Hartman
Quoted 26 lines · Dan Streetman
Quoted 24 lines · Greg Kroah-Hartman
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
Cc Seth Jennings <[email protected]>Cc Dan Streetman <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- mm/zswap.c | 2 -- 1 file changed, 2 deletions(-)mm/zswap.c +0
-2@@ -1262,8 +1262,6 @@ static int __init zswap_debugfs_init(void)return -ENODEV ; zswap_debugfs_root =debugfs_create_dir ("zswap" ,NULL ); -if (!zswap_debugfs_root) -return -ENOMEM ;Quoted 8 lines
mm/zswap.c static int __init zswap_debugfs_init(void) · line 1267
Quoted 2 lines
mm/zswap.c +0
-0debugfs_create_u64 ("pool_limit_hit" ,0444 , zswap_debugfs_root, &zswap_pool_limit_hit);wait, so if i'm reading the code right, in the case where
debugfs_create_dir()returns NULL, that will then be passed along todebugfs_create_u64()as its parent directory - and the debugfs nodes will then get created in the root debugfs directory. That's not what we want to happen...
Quoted 5 lines
True, but that is such a rare thing to ever happen (hint, you have to be out of memory), that it's not really a bad thing. But, you are not the first to mention this, which is why this patch is on its way to Linus for 5.0-final:
https://lore.kernel.org/lkml/[email protected]/
Ah! Great, in that case then definitely
Quoted 4 lines
thanks,
greg k-h