* [PATCH] hid-wiimote-debug.c: Fix error checking for debugfs_create_file
@ 2023-05-23 17:12 Osama Muhammad
2023-05-30 10:48 ` David Rheinsberg
0 siblings, 1 reply; 3+ messages in thread
From: Osama Muhammad @ 2023-05-23 17:12 UTC (permalink / raw)
To: david.rheinsberg, benjamin.tissoires
Cc: linux-input, linux-kernel, Osama Muhammad
This patch fixes the error checking in hid-wiimote-debug.c in
debugfs_create_file. The correct way to check if an error occurred
is 'IS_ERR' inline function.
Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
---
drivers/hid/hid-wiimote-debug.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
index a99dcca2e099..eddd981fee1a 100644
--- a/drivers/hid/hid-wiimote-debug.c
+++ b/drivers/hid/hid-wiimote-debug.c
@@ -183,12 +183,12 @@ int wiidebug_init(struct wiimote_data *wdata)
dbg->eeprom = debugfs_create_file("eeprom", S_IRUSR,
dbg->wdata->hdev->debug_dir, dbg, &wiidebug_eeprom_fops);
- if (!dbg->eeprom)
+ if (IS_ERR(dbg->eeprom))
goto err;
dbg->drm = debugfs_create_file("drm", S_IRUSR,
dbg->wdata->hdev->debug_dir, dbg, &wiidebug_drm_fops);
- if (!dbg->drm)
+ if (IS_ERR(dbg->drm))
goto err_drm;
spin_lock_irqsave(&wdata->state.lock, flags);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hid-wiimote-debug.c: Fix error checking for debugfs_create_file
2023-05-23 17:12 [PATCH] hid-wiimote-debug.c: Fix error checking for debugfs_create_file Osama Muhammad
@ 2023-05-30 10:48 ` David Rheinsberg
2023-05-30 11:04 ` Osama Muhammad
0 siblings, 1 reply; 3+ messages in thread
From: David Rheinsberg @ 2023-05-30 10:48 UTC (permalink / raw)
To: Osama Muhammad; +Cc: benjamin.tissoires, linux-input, linux-kernel
Hi
On Tue, 23 May 2023 at 19:13, Osama Muhammad <osmtendev@gmail.com> wrote:
>
> This patch fixes the error checking in hid-wiimote-debug.c in
> debugfs_create_file. The correct way to check if an error occurred
> is 'IS_ERR' inline function.
Please have a look at fs/debugfs/inode.c, especiall the docs of
debugfs_create_file():
477 * NOTE: it's expected that most callers should _ignore_ the errors returned
478 * by this function. Other debugfs functions handle the fact that
the "dentry"
479 * passed to them could be an error and they don't crash in that case.
480 * Drivers should generally work fine even if debugfs fails to init anyway.
I think the current code is fine. If you feel like adjusting it, I
would rather just remove the NULL-check.
Thanks
David
> Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
> ---
> drivers/hid/hid-wiimote-debug.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
> index a99dcca2e099..eddd981fee1a 100644
> --- a/drivers/hid/hid-wiimote-debug.c
> +++ b/drivers/hid/hid-wiimote-debug.c
> @@ -183,12 +183,12 @@ int wiidebug_init(struct wiimote_data *wdata)
>
> dbg->eeprom = debugfs_create_file("eeprom", S_IRUSR,
> dbg->wdata->hdev->debug_dir, dbg, &wiidebug_eeprom_fops);
> - if (!dbg->eeprom)
> + if (IS_ERR(dbg->eeprom))
> goto err;
>
> dbg->drm = debugfs_create_file("drm", S_IRUSR,
> dbg->wdata->hdev->debug_dir, dbg, &wiidebug_drm_fops);
> - if (!dbg->drm)
> + if (IS_ERR(dbg->drm))
> goto err_drm;
>
> spin_lock_irqsave(&wdata->state.lock, flags);
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hid-wiimote-debug.c: Fix error checking for debugfs_create_file
2023-05-30 10:48 ` David Rheinsberg
@ 2023-05-30 11:04 ` Osama Muhammad
0 siblings, 0 replies; 3+ messages in thread
From: Osama Muhammad @ 2023-05-30 11:04 UTC (permalink / raw)
To: David Rheinsberg; +Cc: benjamin.tissoires, linux-input, linux-kernel
Hi,
I will adjust it by sending the revision of the patch by removing NULL-check.
Thanks,
Osmten
On Tue, 30 May 2023 at 15:48, David Rheinsberg
<david.rheinsberg@gmail.com> wrote:
>
> Hi
>
> On Tue, 23 May 2023 at 19:13, Osama Muhammad <osmtendev@gmail.com> wrote:
> >
> > This patch fixes the error checking in hid-wiimote-debug.c in
> > debugfs_create_file. The correct way to check if an error occurred
> > is 'IS_ERR' inline function.
>
> Please have a look at fs/debugfs/inode.c, especiall the docs of
> debugfs_create_file():
>
> 477 * NOTE: it's expected that most callers should _ignore_ the errors returned
> 478 * by this function. Other debugfs functions handle the fact that
> the "dentry"
> 479 * passed to them could be an error and they don't crash in that case.
> 480 * Drivers should generally work fine even if debugfs fails to init anyway.
>
> I think the current code is fine. If you feel like adjusting it, I
> would rather just remove the NULL-check.
>
> Thanks
> David
>
> > Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
> > ---
> > drivers/hid/hid-wiimote-debug.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
> > index a99dcca2e099..eddd981fee1a 100644
> > --- a/drivers/hid/hid-wiimote-debug.c
> > +++ b/drivers/hid/hid-wiimote-debug.c
> > @@ -183,12 +183,12 @@ int wiidebug_init(struct wiimote_data *wdata)
> >
> > dbg->eeprom = debugfs_create_file("eeprom", S_IRUSR,
> > dbg->wdata->hdev->debug_dir, dbg, &wiidebug_eeprom_fops);
> > - if (!dbg->eeprom)
> > + if (IS_ERR(dbg->eeprom))
> > goto err;
> >
> > dbg->drm = debugfs_create_file("drm", S_IRUSR,
> > dbg->wdata->hdev->debug_dir, dbg, &wiidebug_drm_fops);
> > - if (!dbg->drm)
> > + if (IS_ERR(dbg->drm))
> > goto err_drm;
> >
> > spin_lock_irqsave(&wdata->state.lock, flags);
> > --
> > 2.34.1
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-30 11:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-23 17:12 [PATCH] hid-wiimote-debug.c: Fix error checking for debugfs_create_file Osama Muhammad
2023-05-30 10:48 ` David Rheinsberg
2023-05-30 11:04 ` Osama Muhammad
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).