* [PATCH] powerpc: fix debugfs_create_dir error checking
@ 2023-05-28 7:46 ` mirimmad
0 siblings, 0 replies; 12+ messages in thread
From: mirimmad @ 2023-05-28 7:46 UTC (permalink / raw)
To: gregkh
Cc: Immad Mir, Ivan Orlov, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, linuxppc-dev, linux-kernel
From: Immad Mir <mirimmad17@gmail.com>
The debugfs_create_dir returns ERR_PTR incase of an error and the
correct way of checking it by using the IS_ERR inline function, and
not the simple null comparision. This patch fixes this.
Suggested-By: Ivan Orlov <ivan.orlov0322@gmail.com>
Signed-off-by: Immad Mir <mirimmad17@gmail.com>
---
arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
index 6b4eed2ef..262cd6fac 100644
--- a/arch/powerpc/platforms/powernv/opal-xscom.c
+++ b/arch/powerpc/platforms/powernv/opal-xscom.c
@@ -168,7 +168,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
ent->path.size = strlen((char *)ent->path.data);
dir = debugfs_create_dir(ent->name, root);
- if (!dir) {
+ if (IS_ERR(dir)) {
kfree(ent->path.data);
kfree(ent);
return -1;
@@ -190,7 +190,7 @@ static int scom_debug_init(void)
return 0;
root = debugfs_create_dir("scom", arch_debugfs_dir);
- if (!root)
+ if (IS_ERR(root))
return -1;
rc = 0;
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH] powerpc: fix debugfs_create_dir error checking
@ 2023-05-28 7:46 ` mirimmad
0 siblings, 0 replies; 12+ messages in thread
From: mirimmad @ 2023-05-28 7:46 UTC (permalink / raw)
To: gregkh; +Cc: Ivan Orlov, linux-kernel, Nicholas Piggin, linuxppc-dev, Immad Mir
From: Immad Mir <mirimmad17@gmail.com>
The debugfs_create_dir returns ERR_PTR incase of an error and the
correct way of checking it by using the IS_ERR inline function, and
not the simple null comparision. This patch fixes this.
Suggested-By: Ivan Orlov <ivan.orlov0322@gmail.com>
Signed-off-by: Immad Mir <mirimmad17@gmail.com>
---
arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
index 6b4eed2ef..262cd6fac 100644
--- a/arch/powerpc/platforms/powernv/opal-xscom.c
+++ b/arch/powerpc/platforms/powernv/opal-xscom.c
@@ -168,7 +168,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
ent->path.size = strlen((char *)ent->path.data);
dir = debugfs_create_dir(ent->name, root);
- if (!dir) {
+ if (IS_ERR(dir)) {
kfree(ent->path.data);
kfree(ent);
return -1;
@@ -190,7 +190,7 @@ static int scom_debug_init(void)
return 0;
root = debugfs_create_dir("scom", arch_debugfs_dir);
- if (!root)
+ if (IS_ERR(root))
return -1;
rc = 0;
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] powerpc: fix debugfs_create_dir error checking
2023-05-28 7:46 ` mirimmad
@ 2023-05-28 7:57 ` Greg KH
-1 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2023-05-28 7:57 UTC (permalink / raw)
To: mirimmad
Cc: Immad Mir, Ivan Orlov, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, linuxppc-dev, linux-kernel
On Sun, May 28, 2023 at 01:16:44PM +0530, mirimmad@outlook.com wrote:
> From: Immad Mir <mirimmad17@gmail.com>
>
> The debugfs_create_dir returns ERR_PTR incase of an error and the
> correct way of checking it by using the IS_ERR inline function, and
> not the simple null comparision. This patch fixes this.
>
> Suggested-By: Ivan Orlov <ivan.orlov0322@gmail.com>
> Signed-off-by: Immad Mir <mirimmad17@gmail.com>
> ---
> arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
> index 6b4eed2ef..262cd6fac 100644
> --- a/arch/powerpc/platforms/powernv/opal-xscom.c
> +++ b/arch/powerpc/platforms/powernv/opal-xscom.c
> @@ -168,7 +168,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
> ent->path.size = strlen((char *)ent->path.data);
>
> dir = debugfs_create_dir(ent->name, root);
> - if (!dir) {
> + if (IS_ERR(dir)) {
> kfree(ent->path.data);
> kfree(ent);
> return -1;
Why is this driver caring if debugfs is working or not at all? It
should just ignore the error and keep moving forward.
And -1 is not a valid error number :(
Have you hit this error on this driver?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] powerpc: fix debugfs_create_dir error checking
@ 2023-05-28 7:57 ` Greg KH
0 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2023-05-28 7:57 UTC (permalink / raw)
To: mirimmad
Cc: Ivan Orlov, linux-kernel, Nicholas Piggin, linuxppc-dev, Immad Mir
On Sun, May 28, 2023 at 01:16:44PM +0530, mirimmad@outlook.com wrote:
> From: Immad Mir <mirimmad17@gmail.com>
>
> The debugfs_create_dir returns ERR_PTR incase of an error and the
> correct way of checking it by using the IS_ERR inline function, and
> not the simple null comparision. This patch fixes this.
>
> Suggested-By: Ivan Orlov <ivan.orlov0322@gmail.com>
> Signed-off-by: Immad Mir <mirimmad17@gmail.com>
> ---
> arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
> index 6b4eed2ef..262cd6fac 100644
> --- a/arch/powerpc/platforms/powernv/opal-xscom.c
> +++ b/arch/powerpc/platforms/powernv/opal-xscom.c
> @@ -168,7 +168,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
> ent->path.size = strlen((char *)ent->path.data);
>
> dir = debugfs_create_dir(ent->name, root);
> - if (!dir) {
> + if (IS_ERR(dir)) {
> kfree(ent->path.data);
> kfree(ent);
> return -1;
Why is this driver caring if debugfs is working or not at all? It
should just ignore the error and keep moving forward.
And -1 is not a valid error number :(
Have you hit this error on this driver?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] powerpc: fix debugfs_create_dir error checking
2023-05-28 7:57 ` Greg KH
(?)
@ 2023-05-28 8:06 ` Immad Mir
-1 siblings, 0 replies; 12+ messages in thread
From: Immad Mir @ 2023-05-28 8:06 UTC (permalink / raw)
To: Greg KH; +Cc: Ivan Orlov, mirimmad, linux-kernel, Nicholas Piggin, linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 1815 bytes --]
> Why is this driver caring if debugfs is working or not at all? It
> should just ignore the error and keep moving forward.
I do not know. But, if the authors of the driver have decided to check for
the error, maybe use the more appropriate way?
Thanks.
Immad.
On Sun, May 28, 2023 at 1:27 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> On Sun, May 28, 2023 at 01:16:44PM +0530, mirimmad@outlook.com wrote:
> > From: Immad Mir <mirimmad17@gmail.com>
> >
> > The debugfs_create_dir returns ERR_PTR incase of an error and the
> > correct way of checking it by using the IS_ERR inline function, and
> > not the simple null comparision. This patch fixes this.
> >
> > Suggested-By: Ivan Orlov <ivan.orlov0322@gmail.com>
> > Signed-off-by: Immad Mir <mirimmad17@gmail.com>
> > ---
> > arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c
> b/arch/powerpc/platforms/powernv/opal-xscom.c
> > index 6b4eed2ef..262cd6fac 100644
> > --- a/arch/powerpc/platforms/powernv/opal-xscom.c
> > +++ b/arch/powerpc/platforms/powernv/opal-xscom.c
> > @@ -168,7 +168,7 @@ static int scom_debug_init_one(struct dentry *root,
> struct device_node *dn,
> > ent->path.size = strlen((char *)ent->path.data);
> >
> > dir = debugfs_create_dir(ent->name, root);
> > - if (!dir) {
> > + if (IS_ERR(dir)) {
> > kfree(ent->path.data);
> > kfree(ent);
> > return -1;
>
> Why is this driver caring if debugfs is working or not at all? It
> should just ignore the error and keep moving forward.
>
> And -1 is not a valid error number :(
>
> Have you hit this error on this driver?
>
> thanks,
>
> greg k-h
>
[-- Attachment #2: Type: text/html, Size: 2633 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] powerpc: fix debugfs_create_dir error checking
2023-05-28 7:57 ` Greg KH
@ 2023-05-30 10:47 ` Michael Ellerman
-1 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2023-05-30 10:47 UTC (permalink / raw)
To: Greg KH, mirimmad
Cc: Immad Mir, Ivan Orlov, Nicholas Piggin, Christophe Leroy,
linuxppc-dev, linux-kernel
Greg KH <gregkh@linuxfoundation.org> writes:
> On Sun, May 28, 2023 at 01:16:44PM +0530, mirimmad@outlook.com wrote:
>> From: Immad Mir <mirimmad17@gmail.com>
>>
>> The debugfs_create_dir returns ERR_PTR incase of an error and the
>> correct way of checking it by using the IS_ERR inline function, and
>> not the simple null comparision. This patch fixes this.
>>
>> Suggested-By: Ivan Orlov <ivan.orlov0322@gmail.com>
>> Signed-off-by: Immad Mir <mirimmad17@gmail.com>
>> ---
>> arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
>> index 6b4eed2ef..262cd6fac 100644
>> --- a/arch/powerpc/platforms/powernv/opal-xscom.c
>> +++ b/arch/powerpc/platforms/powernv/opal-xscom.c
>> @@ -168,7 +168,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
>> ent->path.size = strlen((char *)ent->path.data);
>>
>> dir = debugfs_create_dir(ent->name, root);
>> - if (!dir) {
>> + if (IS_ERR(dir)) {
>> kfree(ent->path.data);
>> kfree(ent);
>> return -1;
>
> Why is this driver caring if debugfs is working or not at all? It
> should just ignore the error and keep moving forward.
It's creating directories and then creating files in those directories.
So I think it makes sense that it checks that the directory was created
successfully. It doesn't check whether the files were created.
> And -1 is not a valid error number :(
It's EPERM :) - but yeah probably not really the right error in this
case.
Still I think this patch is an improvement so I'll plan to merge it.
cheers
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] powerpc: fix debugfs_create_dir error checking
@ 2023-05-30 10:47 ` Michael Ellerman
0 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2023-05-30 10:47 UTC (permalink / raw)
To: Greg KH, mirimmad
Cc: Ivan Orlov, linux-kernel, Nicholas Piggin, linuxppc-dev, Immad Mir
Greg KH <gregkh@linuxfoundation.org> writes:
> On Sun, May 28, 2023 at 01:16:44PM +0530, mirimmad@outlook.com wrote:
>> From: Immad Mir <mirimmad17@gmail.com>
>>
>> The debugfs_create_dir returns ERR_PTR incase of an error and the
>> correct way of checking it by using the IS_ERR inline function, and
>> not the simple null comparision. This patch fixes this.
>>
>> Suggested-By: Ivan Orlov <ivan.orlov0322@gmail.com>
>> Signed-off-by: Immad Mir <mirimmad17@gmail.com>
>> ---
>> arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
>> index 6b4eed2ef..262cd6fac 100644
>> --- a/arch/powerpc/platforms/powernv/opal-xscom.c
>> +++ b/arch/powerpc/platforms/powernv/opal-xscom.c
>> @@ -168,7 +168,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
>> ent->path.size = strlen((char *)ent->path.data);
>>
>> dir = debugfs_create_dir(ent->name, root);
>> - if (!dir) {
>> + if (IS_ERR(dir)) {
>> kfree(ent->path.data);
>> kfree(ent);
>> return -1;
>
> Why is this driver caring if debugfs is working or not at all? It
> should just ignore the error and keep moving forward.
It's creating directories and then creating files in those directories.
So I think it makes sense that it checks that the directory was created
successfully. It doesn't check whether the files were created.
> And -1 is not a valid error number :(
It's EPERM :) - but yeah probably not really the right error in this
case.
Still I think this patch is an improvement so I'll plan to merge it.
cheers
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] powerpc: fix debugfs_create_dir error checking
2023-05-30 10:47 ` Michael Ellerman
(?)
@ 2023-06-03 14:33 ` Immad Mir
-1 siblings, 0 replies; 12+ messages in thread
From: Immad Mir @ 2023-06-03 14:33 UTC (permalink / raw)
To: Michael Ellerman
Cc: Ivan Orlov, Greg KH, mirimmad, linux-kernel, Nicholas Piggin,
linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 2068 bytes --]
> Still I think this patch is an improvement so I'll plan to merge it.
Please let me know when you commit it.
Thanks
Immad.
On Tue, May 30, 2023 at 4:17 PM Michael Ellerman <mpe@ellerman.id.au> wrote:
> Greg KH <gregkh@linuxfoundation.org> writes:
> > On Sun, May 28, 2023 at 01:16:44PM +0530, mirimmad@outlook.com wrote:
> >> From: Immad Mir <mirimmad17@gmail.com>
> >>
> >> The debugfs_create_dir returns ERR_PTR incase of an error and the
> >> correct way of checking it by using the IS_ERR inline function, and
> >> not the simple null comparision. This patch fixes this.
> >>
> >> Suggested-By: Ivan Orlov <ivan.orlov0322@gmail.com>
> >> Signed-off-by: Immad Mir <mirimmad17@gmail.com>
> >> ---
> >> arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
> >> 1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c
> b/arch/powerpc/platforms/powernv/opal-xscom.c
> >> index 6b4eed2ef..262cd6fac 100644
> >> --- a/arch/powerpc/platforms/powernv/opal-xscom.c
> >> +++ b/arch/powerpc/platforms/powernv/opal-xscom.c
> >> @@ -168,7 +168,7 @@ static int scom_debug_init_one(struct dentry *root,
> struct device_node *dn,
> >> ent->path.size = strlen((char *)ent->path.data);
> >>
> >> dir = debugfs_create_dir(ent->name, root);
> >> - if (!dir) {
> >> + if (IS_ERR(dir)) {
> >> kfree(ent->path.data);
> >> kfree(ent);
> >> return -1;
> >
> > Why is this driver caring if debugfs is working or not at all? It
> > should just ignore the error and keep moving forward.
>
> It's creating directories and then creating files in those directories.
> So I think it makes sense that it checks that the directory was created
> successfully. It doesn't check whether the files were created.
>
> > And -1 is not a valid error number :(
>
> It's EPERM :) - but yeah probably not really the right error in this
> case.
>
> Still I think this patch is an improvement so I'll plan to merge it.
>
> cheers
>
[-- Attachment #2: Type: text/html, Size: 3054 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] powerpc: fix debugfs_create_dir error checking
2023-05-28 7:46 ` mirimmad
@ 2023-08-31 4:02 ` Michael Ellerman
-1 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2023-08-31 4:02 UTC (permalink / raw)
To: gregkh, mirimmad
Cc: Immad Mir, Ivan Orlov, Nicholas Piggin, Christophe Leroy,
linuxppc-dev, linux-kernel
On Sun, 28 May 2023 13:16:44 +0530, mirimmad@outlook.com wrote:
> The debugfs_create_dir returns ERR_PTR incase of an error and the
> correct way of checking it by using the IS_ERR inline function, and
> not the simple null comparision. This patch fixes this.
>
>
Applied to powerpc/next.
[1/1] powerpc: fix debugfs_create_dir error checking
https://git.kernel.org/powerpc/c/429356fac0440b962aaa6d3688709813a21dd122
cheers
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] powerpc: fix debugfs_create_dir error checking
@ 2023-05-13 15:11 ` mirimmad
0 siblings, 0 replies; 12+ messages in thread
From: mirimmad @ 2023-05-13 15:11 UTC (permalink / raw)
Cc: skhan, Immad Mir, Ivan Orlov, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, linuxppc-dev, linux-kernel
From: Immad Mir <mirimmad17@gmail.com>
The debugfs_create_dir returns ERR_PTR incase of an error and the
correct way of checking it by using the IS_ERR inline function, and
not the simple null comparision. This patch fixes this.
Suggested-By: Ivan Orlov <ivan.orlov0322@gmail.com>
Signed-off-by: Immad Mir <mirimmad17@gmail.com>
---
arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
index 6b4eed2ef..262cd6fac 100644
--- a/arch/powerpc/platforms/powernv/opal-xscom.c
+++ b/arch/powerpc/platforms/powernv/opal-xscom.c
@@ -168,7 +168,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
ent->path.size = strlen((char *)ent->path.data);
dir = debugfs_create_dir(ent->name, root);
- if (!dir) {
+ if (IS_ERR(dir)) {
kfree(ent->path.data);
kfree(ent);
return -1;
@@ -190,7 +190,7 @@ static int scom_debug_init(void)
return 0;
root = debugfs_create_dir("scom", arch_debugfs_dir);
- if (!root)
+ if (IS_ERR(root))
return -1;
rc = 0;
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH] powerpc: fix debugfs_create_dir error checking
@ 2023-05-13 15:11 ` mirimmad
0 siblings, 0 replies; 12+ messages in thread
From: mirimmad @ 2023-05-13 15:11 UTC (permalink / raw)
Cc: Ivan Orlov, linux-kernel, Nicholas Piggin, skhan, linuxppc-dev,
Immad Mir
From: Immad Mir <mirimmad17@gmail.com>
The debugfs_create_dir returns ERR_PTR incase of an error and the
correct way of checking it by using the IS_ERR inline function, and
not the simple null comparision. This patch fixes this.
Suggested-By: Ivan Orlov <ivan.orlov0322@gmail.com>
Signed-off-by: Immad Mir <mirimmad17@gmail.com>
---
arch/powerpc/platforms/powernv/opal-xscom.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
index 6b4eed2ef..262cd6fac 100644
--- a/arch/powerpc/platforms/powernv/opal-xscom.c
+++ b/arch/powerpc/platforms/powernv/opal-xscom.c
@@ -168,7 +168,7 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
ent->path.size = strlen((char *)ent->path.data);
dir = debugfs_create_dir(ent->name, root);
- if (!dir) {
+ if (IS_ERR(dir)) {
kfree(ent->path.data);
kfree(ent);
return -1;
@@ -190,7 +190,7 @@ static int scom_debug_init(void)
return 0;
root = debugfs_create_dir("scom", arch_debugfs_dir);
- if (!root)
+ if (IS_ERR(root))
return -1;
rc = 0;
--
2.40.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-08-31 4:07 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-28 7:46 [PATCH] powerpc: fix debugfs_create_dir error checking mirimmad
2023-05-28 7:46 ` mirimmad
2023-05-28 7:57 ` Greg KH
2023-05-28 7:57 ` Greg KH
2023-05-28 8:06 ` Immad Mir
2023-05-30 10:47 ` Michael Ellerman
2023-05-30 10:47 ` Michael Ellerman
2023-06-03 14:33 ` Immad Mir
2023-08-31 4:02 ` Michael Ellerman
2023-08-31 4:02 ` Michael Ellerman
-- strict thread matches above, loose matches on Subject: below --
2023-05-13 15:11 mirimmad
2023-05-13 15:11 ` mirimmad
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.