[PATCH] nfcsim.c: Fix error checking for debugfs_create_dir

Simon Horman simon.horman at corigine.com
Thu May 25 01:12:19 PDT 2023


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 at 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 at 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




More information about the Linux-mediatek mailing list