public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: + zram-fix-error-return-code.patch added to -mm tree
       [not found] <5522e1c7.85EYdVI5AOC58VOT%akpm@linux-foundation.org>
@ 2015-04-07  1:56 ` Sergey Senozhatsky
  0 siblings, 0 replies; only message in thread
From: Sergey Senozhatsky @ 2015-04-07  1:56 UTC (permalink / raw)
  To: akpm; +Cc: Julia.Lawall, minchan, ngupta, mm-commits, linux-kernel

On (04/06/15 12:43), akpm@linux-foundation.org wrote:
> From: Julia Lawall <Julia.Lawall@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.Lawall@lip6.fr>
> Cc: Minchan Kim <minchan@kernel.org>
> Cc: Nitin Gupta <ngupta@vflare.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---

good catch.
Acked-by: Sergey Senozhatsky <sergey.senozhatsky.work@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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-04-07  1:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <5522e1c7.85EYdVI5AOC58VOT%akpm@linux-foundation.org>
2015-04-07  1:56 ` + zram-fix-error-return-code.patch added to -mm tree Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox