linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] debugfs.c: Fix error checking for debugfs_create_dir
@ 2023-05-24 16:03 Osama Muhammad
       [not found] ` <20230524155506.19353-1-osmtendev@gmail.com>
  2023-05-30 10:29 ` [PATCH] debugfs.c: " Kalle Valo
  0 siblings, 2 replies; 5+ messages in thread
From: Osama Muhammad @ 2023-05-24 16:03 UTC (permalink / raw)
  To: nbd, ryder.lee, lorenzo, shayne.chen, davem
  Cc: linux-wireless, linux-mediatek, linux-kernel, Osama Muhammad

This patch fixes the error checking in debugfs.c in
debugfs_create_dir. The correct way to check if an error occurred
is using 'IS_ERR' inline function.

Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
---
 drivers/net/wireless/mediatek/mt76/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/debugfs.c b/drivers/net/wireless/mediatek/mt76/debugfs.c
index 57fbcc83e074..d9ba700131fd 100644
--- a/drivers/net/wireless/mediatek/mt76/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/debugfs.c
@@ -109,7 +109,7 @@ mt76_register_debugfs_fops(struct mt76_phy *phy,
 	struct dentry *dir;
 
 	dir = debugfs_create_dir("mt76", phy->hw->wiphy->debugfsdir);
-	if (!dir)
+	if (IS_ERR(dir))
 		return NULL;
 
 	debugfs_create_u8("led_pin", 0600, dir, &phy->leds.pin);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] nfcsim.c: Fix error checking for debugfs_create_dir
       [not found] ` <20230524155506.19353-1-osmtendev@gmail.com>
@ 2023-05-25  8:12   ` Simon Horman
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2023-05-25  8:12 UTC (permalink / raw)
  To: Osama Muhammad
  Cc: krzysztof.kozlowski, netdev, linux-kernel, nbd, ryder.lee,
	lorenzo, shayne.chen, davem, linux-wireless, linux-mediatek

On Wed, May 24, 2023 at 08:55:06PM +0500, Osama Muhammad wrote:
> This patch fixes the error checking in nfcsim.c in
> debugfs_create_dir. The correct way to check if an error occurred
> is using 'IS_ERR' inline function.
> 
> Signed-off-by: Osama Muhammad <osmtendev@gmail.com>

...

On Wed, May 24, 2023 at 09:03:52PM +0500, Osama Muhammad wrote:
> This patch fixes the error checking in debugfs.c in
> debugfs_create_dir. The correct way to check if an error occurred
> is using 'IS_ERR' inline function.
> 
> Signed-off-by: Osama Muhammad <osmtendev@gmail.com>

...

The comment above debugfs_create_dir includes the following text.

 * NOTE: it's expected that most callers should _ignore_ the errors returned
 * by this function. Other debugfs functions handle the fact that the "dentry"
 * passed to them could be an error and they don't crash in that case.
 * Drivers should generally work fine even if debugfs fails to init anyway.

And I notice that in this same file there are calls to debugfs_create_dir()
where that advice is followed: the return value is ignored.

So I think the correct approaches here are to either:

1. Do nothing, the code isn't really broken
2. Remove the error checking

-- 
pw-bot: cr


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] debugfs.c: Fix error checking for debugfs_create_dir
  2023-05-24 16:03 [PATCH] debugfs.c: Fix error checking for debugfs_create_dir Osama Muhammad
       [not found] ` <20230524155506.19353-1-osmtendev@gmail.com>
@ 2023-05-30 10:29 ` Kalle Valo
  2023-05-30 11:02   ` Osama Muhammad
  1 sibling, 1 reply; 5+ messages in thread
From: Kalle Valo @ 2023-05-30 10:29 UTC (permalink / raw)
  To: Osama Muhammad
  Cc: nbd, ryder.lee, lorenzo, shayne.chen, davem, linux-wireless,
	linux-mediatek, linux-kernel

Osama Muhammad <osmtendev@gmail.com> writes:

> This patch fixes the error checking in debugfs.c in
> debugfs_create_dir. The correct way to check if an error occurred
> is using 'IS_ERR' inline function.
>
> Signed-off-by: Osama Muhammad <osmtendev@gmail.com>

The title is wrong, please see the wiki page below how to create titles.

Also no need to say "This patch fixes..", saying "Fix..." is enough.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] debugfs.c: Fix error checking for debugfs_create_dir
  2023-05-30 10:29 ` [PATCH] debugfs.c: " Kalle Valo
@ 2023-05-30 11:02   ` Osama Muhammad
  2023-05-30 11:19     ` Osama Muhammad
  0 siblings, 1 reply; 5+ messages in thread
From: Osama Muhammad @ 2023-05-30 11:02 UTC (permalink / raw)
  To: Kalle Valo
  Cc: nbd, ryder.lee, lorenzo, shayne.chen, davem, linux-wireless,
	linux-mediatek, linux-kernel

Hi,

I will keep that in mind and send with the right subject while
submitting a revision of the patch.

Regarding the patch after researching more into it I have come to know
that the debugfs
API will not return null on error but an ERR_PTR. The modern wisdom
about it is to ignore the errors returned by the function as stated in
the comment  above the function debugfs_create_file.

> * NOTE: it's expected that most callers should _ignore_ the errors returned
 >* by this function. Other debugfs functions handle the fact that the "dentry"
 >* passed to them could be an error and they don't crash in that case.
> * Drivers should generally work fine even if debugfs fails to init anyway.
Here is the link to comment :-
https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L451

Considering this, I will send the revision of the patch by removing
error checks. Please correct me if  there are any concerns with this.

Thanks,
Osmten

On Tue, 30 May 2023 at 15:29, Kalle Valo <kvalo@kernel.org> wrote:
>
> Osama Muhammad <osmtendev@gmail.com> writes:
>
> > This patch fixes the error checking in debugfs.c in
> > debugfs_create_dir. The correct way to check if an error occurred
> > is using 'IS_ERR' inline function.
> >
> > Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
>
> The title is wrong, please see the wiki page below how to create titles.
>
> Also no need to say "This patch fixes..", saying "Fix..." is enough.
>
> --
> https://patchwork.kernel.org/project/linux-wireless/list/
>
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] debugfs.c: Fix error checking for debugfs_create_dir
  2023-05-30 11:02   ` Osama Muhammad
@ 2023-05-30 11:19     ` Osama Muhammad
  0 siblings, 0 replies; 5+ messages in thread
From: Osama Muhammad @ 2023-05-30 11:19 UTC (permalink / raw)
  To: Kalle Valo
  Cc: nbd, ryder.lee, lorenzo, shayne.chen, davem, linux-wireless,
	linux-mediatek, linux-kernel

Hi,

In the previous email mistakenly I have referenced debugfs_create_file
but it's the same for debugfs_create_dir also.

Here is the link to comment above the function debugfs_create_dir
https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L564

Thanks,
Osmten

On Tue, 30 May 2023 at 16:02, Osama Muhammad <osmtendev@gmail.com> wrote:
>
> Hi,
>
> I will keep that in mind and send with the right subject while
> submitting a revision of the patch.
>
> Regarding the patch after researching more into it I have come to know
> that the debugfs
> API will not return null on error but an ERR_PTR. The modern wisdom
> about it is to ignore the errors returned by the function as stated in
> the comment  above the function debugfs_create_file.
>
> > * NOTE: it's expected that most callers should _ignore_ the errors returned
>  >* by this function. Other debugfs functions handle the fact that the "dentry"
>  >* passed to them could be an error and they don't crash in that case.
> > * Drivers should generally work fine even if debugfs fails to init anyway.
> Here is the link to comment :-
> https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L451
>
> Considering this, I will send the revision of the patch by removing
> error checks. Please correct me if  there are any concerns with this.
>
> Thanks,
> Osmten
>
> On Tue, 30 May 2023 at 15:29, Kalle Valo <kvalo@kernel.org> wrote:
> >
> > Osama Muhammad <osmtendev@gmail.com> writes:
> >
> > > This patch fixes the error checking in debugfs.c in
> > > debugfs_create_dir. The correct way to check if an error occurred
> > > is using 'IS_ERR' inline function.
> > >
> > > Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
> >
> > The title is wrong, please see the wiki page below how to create titles.
> >
> > Also no need to say "This patch fixes..", saying "Fix..." is enough.
> >
> > --
> > https://patchwork.kernel.org/project/linux-wireless/list/
> >
> > https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-05-30 11:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-24 16:03 [PATCH] debugfs.c: Fix error checking for debugfs_create_dir Osama Muhammad
     [not found] ` <20230524155506.19353-1-osmtendev@gmail.com>
2023-05-25  8:12   ` [PATCH] nfcsim.c: " Simon Horman
2023-05-30 10:29 ` [PATCH] debugfs.c: " Kalle Valo
2023-05-30 11:02   ` Osama Muhammad
2023-05-30 11:19     ` 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).