xen/debugfs: Check debugfs initialization before using it
Subsystems (2)
PATCH v3 1/1 xen/debugfs: Check debugfs initialization before using it
From: "ethan.zhao" <[email protected]>
Should check debugfs initialization with debugfs_initialized() before using it, Because if it isn't initialized, the return value of fake debugfs_create_dir() etc functions would be ERR_PTR(-ENODEV), checking with NULL will not work.
V3: add warning message when debugfs not configured or disabled.
--- arch/x86/xen/debugfs.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/x86/xen/debugfs.c +6 -0
@@ -9,12 +9,18 @@ static struct dentry *d_xen_debug;struct dentry *__init xen_init_debugfs (void ) { +if (!debugfs_initialized ()) { + d_xen_debug =NULL ; + goto nodebugfs; + } +if (!d_xen_debug) { d_xen_debug =debugfs_create_dir ("xen" ,NULL );if (!d_xen_debug)pr_warning ("Could not create 'xen' debugfs directory\n" ); } +nodebugfs:return d_xen_debug; }
Signature · 1 line
1.8.3.4 (Apple Git-47)
Greg,
How about the V3 ?
Thanks,
Ethan
Quoted 39 lines · Ethan Zhao
From: "ethan.zhao" <[email protected]>
Should check debugfs initialization with
debugfs_initialized()before using it, Because if it isn't initialized, the return value of fakedebugfs_create_dir()etc functions would beERR_PTR(-ENODEV), checking with NULL will not work.V3: add warning message when debugfs not configured or disabled.
Signed-off-by ethan.zhao <[email protected]>--- arch/x86/xen/debugfs.c | 6 ++++++ 1 file changed, 6 insertions(+)arch/x86/xen/debugfs.c +6
-1@@ -9,12 +9,18 @@ static struct dentry *d_xen_debug;struct dentry *__init xen_init_debugfs (void ) { +if (!debugfs_initialized ()) { + d_xen_debug =NULL ; + goto nodebugfs; + } +if (!d_xen_debug) { d_xen_debug =debugfs_create_dir ("xen" ,NULL );if (!d_xen_debug)pr_warning ("Could not create 'xen' debugfs directory\n" ); } +nodebugfs:return d_xen_debug; } --1.8.3.4 (Apple Git-47)
Quoted 7 lines · Ethan Zhao
From: "ethan.zhao" <[email protected]>
Should check debugfs initialization with
debugfs_initialized()before using it, Because if it isn't initialized, the return value of fakedebugfs_create_dir()etc functions would beERR_PTR(-ENODEV), checking with NULL will not work.V3: add warning message when debugfs not configured or disabled.
That's not what this patch does...
Quoted 10 lines
Signed-off-by ethan.zhao <[email protected]>--- arch/x86/xen/debugfs.c | 6 ++++++ 1 file changed, 6 insertions(+)arch/x86/xen/debugfs.c +0
-0
arch/x86/xen/debugfs.c static struct dentry *d_xen_debug; · line 15
Quoted 7 lines
arch/x86/xen/debugfs.c +4
-0@@ -9,12 +9,18 @@ static struct dentry *d_xen_debug;struct dentry *__init xen_init_debugfs (void ) { +if (!debugfs_initialized ()) { + d_xen_debug =NULL ; + goto nodebugfs; + }
Again, why is this even needed?
What problem in the existing code are you trying to solve?
Quoted 31 lines · Greg KH
Quoted 7 lines · Ethan Zhao
From: "ethan.zhao" <[email protected]>
Should check debugfs initialization with
debugfs_initialized()before using it, Because if it isn't initialized, the return value of fakedebugfs_create_dir()etc functions would beERR_PTR(-ENODEV), checking with NULL will not work.V3: add warning message when debugfs not configured or disabled.
That's not what this patch does...
Quoted 10 lines
Signed-off-by ethan.zhao <[email protected]>--- arch/x86/xen/debugfs.c | 6 ++++++ 1 file changed, 6 insertions(+)arch/x86/xen/debugfs.c +0
-0arch/x86/xen/debugfs.c static struct dentry *d_xen_debug; · line 15
Quoted 7 lines
arch/x86/xen/debugfs.c +4
-0@@ -9,12 +9,18 @@ static struct dentry *d_xen_debug;struct dentry *__init xen_init_debugfs (void ) { +if (!debugfs_initialized ()) { + d_xen_debug =NULL ; + goto nodebugfs; + }Again, why is this even needed?
Quoted 2 lines
What problem in the existing code are you trying to solve?
What I want to ask who is so smart and fake some many functions when CONFIG_DEBUG_FS is not configured/defined and the build could pass without any error ? What is the motive make him wrote some many fake function and why he wrote the debugfs_initialized() function seem 'useless' at all ?
Thanks,
Ethan
Quoted 32 lines · Ethan Zhao
Quoted 31 lines · Greg KH
Quoted 7 lines · Ethan Zhao
From: "ethan.zhao" <[email protected]>
Should check debugfs initialization with
debugfs_initialized()before using it, Because if it isn't initialized, the return value of fakedebugfs_create_dir()etc functions would beERR_PTR(-ENODEV), checking with NULL will not work.V3: add warning message when debugfs not configured or disabled.
That's not what this patch does...
Quoted 10 lines
Signed-off-by ethan.zhao <[email protected]>--- arch/x86/xen/debugfs.c | 6 ++++++ 1 file changed, 6 insertions(+)arch/x86/xen/debugfs.c +0
-0arch/x86/xen/debugfs.c static struct dentry *d_xen_debug; · line 15
Quoted 7 lines
arch/x86/xen/debugfs.c +4
-0@@ -9,12 +9,18 @@ static struct dentry *d_xen_debug;struct dentry *__init xen_init_debugfs (void ) { +if (!debugfs_initialized ()) { + d_xen_debug =NULL ; + goto nodebugfs; + }Again, why is this even needed?
Quoted 5 lines
Quoted 2 lines
What problem in the existing code are you trying to solve?
What I want to ask who is so smart and fake some many functions when
CONFIG_DEBUG_FSis not configured/defined and the build could pass without any error ?
That's the way this has always worked.
Quoted 2 lines
What is the motive make him wrote some many fake function and why he wrote the
debugfs_initialized()function seem 'useless' at all ?
To make the caller code easier, and smaller, and to not care if debugfs is enabled in the kernel build or not at all.
Ok, I answered your questions, now care to answer mine?
greg k-h