On (04/06/15 12:43), a...@linux-foundation.org wrote:
> From: Julia Lawall <julia.law...@lip6.fr>
> Subject: zram: fix error return code
> 
> 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/)
> 
> Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
> Cc: Minchan Kim <minc...@kernel.org>
> Cc: Nitin Gupta <ngu...@vflare.org>
> Signed-off-by: Andrew Morton <a...@linux-foundation.org>
> ---

good catch.
Acked-by: Sergey Senozhatsky <sergey.senozhatsky.w...@gmail.com>

>  drivers/block/zram/zram_drv.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff -puN drivers/block/zram/zram_drv.c~zram-fix-error-return-code 
> drivers/block/zram/zram_drv.c
> --- a/drivers/block/zram/zram_drv.c~zram-fix-error-return-code
> +++ a/drivers/block/zram/zram_drv.c
> @@ -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;
>       }

I think we can drop the default `ret' value and just return explicit `-ENOMEM' 
in
!zram case.

---
 drivers/block/zram/zram_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index fe67ebb..f444c15 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1164,11 +1164,11 @@ static int zram_add(int device_id)
 {
        struct zram *zram;
        struct request_queue *queue;
-       int ret = -ENOMEM;
+       int ret;
 
        zram = kzalloc(sizeof(struct zram), GFP_KERNEL);
        if (!zram)
-               return ret;
+               return -ENOMEM;
 
        if (device_id < 0) {
                /* generate new device_id */
-- 
2.4.0.rc1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to