Skip to content

Commit

Permalink
MIPS: Modify error handling
Browse files Browse the repository at this point in the history
debugfs_create_file returns NULL on error so an IS_ERR test is
incorrect here and a NULL check is required.

The Coccinelle semantic patch used to make this change is as follows:
@@
expression e;
@@

  e = debugfs_create_file(...);
if(
-    IS_ERR(e)
+    !e
    )
    {
  <+...
  return
- PTR_ERR(e)
+ -ENOMEM
  ;
  ...+>
  }

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Cc: julia.lawall@lip6.fr
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/13834/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Amitoj Kaur Chawla authored and Ralf Baechle committed Aug 1, 2016
1 parent 11f7690 commit 33799a6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/mips/mm/sc-debugfs.c
Original file line number Diff line number Diff line change
@@ -73,8 +73,8 @@ static int __init sc_debugfs_init(void)

file = debugfs_create_file("prefetch", S_IRUGO | S_IWUSR, dir,
NULL, &sc_prefetch_fops);
if (IS_ERR(file))
return PTR_ERR(file);
if (!file)
return -ENOMEM;

return 0;
}

0 comments on commit 33799a6

Please sign in to comment.