MIPS: Modify error handling
authorAmitoj Kaur Chawla <amitoj1606@gmail.com>
Fri, 29 Jul 2016 08:28:46 +0000 (13:58 +0530)
committerRalf Baechle <ralf@linux-mips.org>
Mon, 1 Aug 2016 20:54:48 +0000 (22:54 +0200)
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>
arch/mips/mm/sc-debugfs.c

index 5eefe3281b246bf53d69c0d89e2750dc5fbb29e1..01f1154cdb0cd75f2c1f942c46ef09c7f3127e39 100644 (file)
@@ -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;
 }