From: Michael Ellerman <mpe@ellerman.id.au>
To: Greg KH <gregkh@linuxfoundation.org>, mirimmad@outlook.com
Cc: Ivan Orlov <ivan.orlov0322@gmail.com>,
linux-kernel@vger.kernel.org, Nicholas Piggin <npiggin@gmail.com>,
linuxppc-dev@lists.ozlabs.org, Immad Mir <mirimmad17@gmail.com>
Subject: Re: [PATCH] powerpc: fix debugfs_create_dir error checking
Date: Tue, 30 May 2023 20:47:21 +1000 [thread overview]
Message-ID: <87zg5mrt8m.fsf@mail.lhotse> (raw)
In-Reply-To: <2023052835-oxidant-doily-404f@gregkh>
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
WARNING: multiple messages have this Message-ID (diff)
From: Michael Ellerman <mpe@ellerman.id.au>
To: Greg KH <gregkh@linuxfoundation.org>, mirimmad@outlook.com
Cc: Immad Mir <mirimmad17@gmail.com>,
Ivan Orlov <ivan.orlov0322@gmail.com>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powerpc: fix debugfs_create_dir error checking
Date: Tue, 30 May 2023 20:47:21 +1000 [thread overview]
Message-ID: <87zg5mrt8m.fsf@mail.lhotse> (raw)
In-Reply-To: <2023052835-oxidant-doily-404f@gregkh>
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
next prev parent reply other threads:[~2023-05-30 10:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zg5mrt8m.fsf@mail.lhotse \
--to=mpe@ellerman.id.au \
--cc=gregkh@linuxfoundation.org \
--cc=ivan.orlov0322@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mirimmad17@gmail.com \
--cc=mirimmad@outlook.com \
--cc=npiggin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.