[1/2] media: siano: Fix the NULL vs IS_ERR() bug for debugfs_create_file()
Commit Message
Since debugfs_create_file() returns ERR_PTR and never NULL, use IS_ERR() to
check the return value.
Fixes: 503efe5cfc9f ("[media] siano: split debugfs code into a separate file")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
drivers/media/common/siano/smsdvb-debugfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 14/09/2023 05:50, Jinjie Ruan wrote:
> Since debugfs_create_file() returns ERR_PTR and never NULL, use IS_ERR() to
> check the return value.
>
> Fixes: 503efe5cfc9f ("[media] siano: split debugfs code into a separate file")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> drivers/media/common/siano/smsdvb-debugfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/common/siano/smsdvb-debugfs.c b/drivers/media/common/siano/smsdvb-debugfs.c
> index e0beefd80d7b..16d3b9ab31c5 100644
> --- a/drivers/media/common/siano/smsdvb-debugfs.c
> +++ b/drivers/media/common/siano/smsdvb-debugfs.c
> @@ -369,7 +369,7 @@ int smsdvb_debugfs_create(struct smsdvb_client_t *client)
>
> d = debugfs_create_file("stats", S_IRUGO | S_IWUSR, client->debugfs,
> client, &debugfs_stats_ops);
> - if (!d) {
> + if (IS_ERR(d)) {
> debugfs_remove(client->debugfs);
> return -ENOMEM;
> }
Actually, standard behavior is not to check the error at all. It is not
considered a bug if creating a debugfs directory fails, you can just continue.
So rather than 'fixing' this, just drop the error check completely.
See e.g. commit 8c23f411296e ("media: sti: no need to check return value of
debugfs_create functions").
Regards,
Hans
@@ -369,7 +369,7 @@ int smsdvb_debugfs_create(struct smsdvb_client_t *client)
d = debugfs_create_file("stats", S_IRUGO | S_IWUSR, client->debugfs,
client, &debugfs_stats_ops);
- if (!d) {
+ if (IS_ERR(d)) {
debugfs_remove(client->debugfs);
return -ENOMEM;
}