public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: akpm@linux-foundation.org
Cc: Julia.Lawall@lip6.fr, minchan@kernel.org, ngupta@vflare.org,
	mm-commits@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: + zram-fix-error-return-code.patch added to -mm tree
Date: Tue, 7 Apr 2015 10:56:56 +0900	[thread overview]
Message-ID: <20150407015656.GA1859@swordfish> (raw)
In-Reply-To: <5522e1c7.85EYdVI5AOC58VOT%akpm@linux-foundation.org>

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


           reply	other threads:[~2015-04-07  1:56 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <5522e1c7.85EYdVI5AOC58VOT%akpm@linux-foundation.org>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150407015656.GA1859@swordfish \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=Julia.Lawall@lip6.fr \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=ngupta@vflare.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox