netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nfcsim.c: Fix error checking for debugfs_create_dir
@ 2023-05-24 15:55 ` Osama Muhammad
  2023-05-25  8:12   ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Osama Muhammad @ 2023-05-24 15:55 UTC (permalink / raw)
  To: krzysztof.kozlowski; +Cc: netdev, linux-kernel, Osama Muhammad

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>
---
 drivers/nfc/nfcsim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nfc/nfcsim.c b/drivers/nfc/nfcsim.c
index 44eeb17ae48d..3b377704e2b5 100644
--- a/drivers/nfc/nfcsim.c
+++ b/drivers/nfc/nfcsim.c
@@ -337,7 +337,7 @@ static void nfcsim_debugfs_init(void)
 {
 	nfcsim_debugfs_root = debugfs_create_dir("nfcsim", NULL);
 
-	if (!nfcsim_debugfs_root)
+	if (IS_ERR(nfcsim_debugfs_root))
 		pr_err("Could not create debugfs entry\n");
 
 }
-- 
2.34.1


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

* Re: [PATCH] nfcsim.c: Fix error checking for debugfs_create_dir
  2023-05-24 15:55 ` [PATCH] nfcsim.c: Fix error checking for debugfs_create_dir Osama Muhammad
@ 2023-05-25  8:12   ` Simon Horman
  0 siblings, 0 replies; 2+ 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] 2+ messages in thread

end of thread, other threads:[~2023-05-25  8:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230524160352.19704-1-osmtendev@gmail.com>
2023-05-24 15:55 ` [PATCH] nfcsim.c: Fix error checking for debugfs_create_dir Osama Muhammad
2023-05-25  8:12   ` Simon Horman

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).