All of lore.kernel.org
 help / color / mirror / Atom feed
* + zram-fix-error-return-code.patch added to -mm tree
@ 2015-04-06 19:43 akpm
  2015-04-07  1:56 ` Sergey Senozhatsky
  0 siblings, 1 reply; 2+ messages in thread
From: akpm @ 2015-04-06 19:43 UTC (permalink / raw)
  To: Julia.Lawall, minchan, ngupta, mm-commits


The patch titled
     Subject: zram: fix error return code
has been added to the -mm tree.  Its filename is
     zram-fix-error-return-code.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/zram-fix-error-return-code.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/zram-fix-error-return-code.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
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/)

// <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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 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;
 	}
 
_

Patches currently in -mm which might be from Julia.Lawall@lip6.fr are

zram-fix-error-return-code.patch
linux-next.patch


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: + zram-fix-error-return-code.patch added to -mm tree
  2015-04-06 19:43 + zram-fix-error-return-code.patch added to -mm tree akpm
@ 2015-04-07  1:56 ` Sergey Senozhatsky
  0 siblings, 0 replies; 2+ messages 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] 2+ messages in thread

end of thread, other threads:[~2015-04-07  1:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-06 19:43 + zram-fix-error-return-code.patch added to -mm tree akpm
2015-04-07  1:56 ` Sergey Senozhatsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.