]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
zram: fix error return code
authorJulia Lawall <Julia.Lawall@lip6.fr>
Tue, 7 Apr 2015 23:44:50 +0000 (09:44 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 7 Apr 2015 23:44:50 +0000 (09:44 +1000)
Return a negative error code on failure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
identifier ret; expression e1,e2;
@@
(
if (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Acked-by: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/block/zram/zram_drv.c

index 759ee093d7f85c9af5f1fce3710a3c28eccfdb55..fe67ebbe6c18f5e29c10096f2619450437ed5980 100644 (file)
@@ -1188,6 +1188,7 @@ static int zram_add(int device_id)
        if (!queue) {
                pr_err("Error allocating disk queue for device %d\n",
                        device_id);
+               ret = -ENOMEM;
                goto out_free_idr;
        }
 
@@ -1198,6 +1199,7 @@ static int zram_add(int device_id)
        if (!zram->disk) {
                pr_warn("Error allocating disk structure for device %d\n",
                        device_id);
+               ret = -ENOMEM;
                goto out_free_queue;
        }