* [PATCH] LoongArch: Delete debugfs checking
@ 2023-06-20 8:06 Dan Carpenter
2023-06-28 14:22 ` WANG Xuerui
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2023-06-20 8:06 UTC (permalink / raw)
To: Ivan Orlov, Immad Mir
Cc: WANG Xuerui, Huacai Chen, loongarch, linux-kernel, kernel-janitors
Debugfs functions are not supposed to be checked for errors. This
is sort of unusual but it is described in the comments for the
debugfs_create_dir() function. Also debugfs_create_dir() can never
return NULL.
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
I spotted this code because I was looking at patches which were sent
to stable but without a Fixes tag. The correct way of checking for
error pointers is not IS_ERR_OR_NULL(), it's IS_ERR(). When a function
returns both error pointers and NULL, the NULL should be treated as a
special kind of success. Please see my blog for more details.
https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/
I have not included a Fixes tag here, because it's not really a bug fix,
it's just a clean up.
arch/loongarch/kernel/unaligned.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/loongarch/kernel/unaligned.c b/arch/loongarch/kernel/unaligned.c
index 85fae3d2d71a..3abf163dda05 100644
--- a/arch/loongarch/kernel/unaligned.c
+++ b/arch/loongarch/kernel/unaligned.c
@@ -485,8 +485,6 @@ static int __init debugfs_unaligned(void)
struct dentry *d;
d = debugfs_create_dir("loongarch", NULL);
- if (IS_ERR_OR_NULL(d))
- return -ENOMEM;
debugfs_create_u32("unaligned_instructions_user",
S_IRUGO, d, &unaligned_instructions_user);
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] LoongArch: Delete debugfs checking
2023-06-20 8:06 [PATCH] LoongArch: Delete debugfs checking Dan Carpenter
@ 2023-06-28 14:22 ` WANG Xuerui
2023-06-28 15:37 ` Huacai Chen
0 siblings, 1 reply; 3+ messages in thread
From: WANG Xuerui @ 2023-06-28 14:22 UTC (permalink / raw)
To: Dan Carpenter, Ivan Orlov, Immad Mir
Cc: Huacai Chen, loongarch, linux-kernel, kernel-janitors
Hi,
On 2023/6/20 16:06, Dan Carpenter wrote:
> Debugfs functions are not supposed to be checked for errors. This
> is sort of unusual but it is described in the comments for the
> debugfs_create_dir() function. Also debugfs_create_dir() can never
> return NULL.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> I spotted this code because I was looking at patches which were sent
> to stable but without a Fixes tag. The correct way of checking for
> error pointers is not IS_ERR_OR_NULL(), it's IS_ERR(). When a function
> returns both error pointers and NULL, the NULL should be treated as a
> special kind of success. Please see my blog for more details.
>
> https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/
>
> I have not included a Fixes tag here, because it's not really a bug fix,
> it's just a clean up.
Thanks for the patch and sorry for the late review. I didn't notice this
back then (just recovering from covid around that time) but since
loongarch-next isn't tagged yet I think the patch could make it this
cycle. (Somehow Huacai didn't see the mail either, weird...)
>
> arch/loongarch/kernel/unaligned.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/arch/loongarch/kernel/unaligned.c b/arch/loongarch/kernel/unaligned.c
> index 85fae3d2d71a..3abf163dda05 100644
> --- a/arch/loongarch/kernel/unaligned.c
> +++ b/arch/loongarch/kernel/unaligned.c
> @@ -485,8 +485,6 @@ static int __init debugfs_unaligned(void)
> struct dentry *d;
>
> d = debugfs_create_dir("loongarch", NULL);
> - if (IS_ERR_OR_NULL(d))
> - return -ENOMEM;
>
> debugfs_create_u32("unaligned_instructions_user",
> S_IRUGO, d, &unaligned_instructions_user);
Trivial enough, thanks!
Reviewed-by: WANG Xuerui <git@xen0n.name>
--
WANG "xen0n" Xuerui
Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] LoongArch: Delete debugfs checking
2023-06-28 14:22 ` WANG Xuerui
@ 2023-06-28 15:37 ` Huacai Chen
0 siblings, 0 replies; 3+ messages in thread
From: Huacai Chen @ 2023-06-28 15:37 UTC (permalink / raw)
To: WANG Xuerui
Cc: Dan Carpenter, Ivan Orlov, Immad Mir, loongarch, linux-kernel,
kernel-janitors
Queued for loongarch-next, thanks.
Huacai
On Wed, Jun 28, 2023 at 10:22 PM WANG Xuerui <kernel@xen0n.name> wrote:
>
> Hi,
>
> On 2023/6/20 16:06, Dan Carpenter wrote:
> > Debugfs functions are not supposed to be checked for errors. This
> > is sort of unusual but it is described in the comments for the
> > debugfs_create_dir() function. Also debugfs_create_dir() can never
> > return NULL.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> > I spotted this code because I was looking at patches which were sent
> > to stable but without a Fixes tag. The correct way of checking for
> > error pointers is not IS_ERR_OR_NULL(), it's IS_ERR(). When a function
> > returns both error pointers and NULL, the NULL should be treated as a
> > special kind of success. Please see my blog for more details.
> >
> > https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/
> >
> > I have not included a Fixes tag here, because it's not really a bug fix,
> > it's just a clean up.
>
> Thanks for the patch and sorry for the late review. I didn't notice this
> back then (just recovering from covid around that time) but since
> loongarch-next isn't tagged yet I think the patch could make it this
> cycle. (Somehow Huacai didn't see the mail either, weird...)
>
> >
> > arch/loongarch/kernel/unaligned.c | 2 --
> > 1 file changed, 2 deletions(-)
> >
> > diff --git a/arch/loongarch/kernel/unaligned.c b/arch/loongarch/kernel/unaligned.c
> > index 85fae3d2d71a..3abf163dda05 100644
> > --- a/arch/loongarch/kernel/unaligned.c
> > +++ b/arch/loongarch/kernel/unaligned.c
> > @@ -485,8 +485,6 @@ static int __init debugfs_unaligned(void)
> > struct dentry *d;
> >
> > d = debugfs_create_dir("loongarch", NULL);
> > - if (IS_ERR_OR_NULL(d))
> > - return -ENOMEM;
> >
> > debugfs_create_u32("unaligned_instructions_user",
> > S_IRUGO, d, &unaligned_instructions_user);
>
> Trivial enough, thanks!
>
> Reviewed-by: WANG Xuerui <git@xen0n.name>
>
> --
> WANG "xen0n" Xuerui
>
> Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-28 15:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-20 8:06 [PATCH] LoongArch: Delete debugfs checking Dan Carpenter
2023-06-28 14:22 ` WANG Xuerui
2023-06-28 15:37 ` Huacai Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®