lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20150407015656.GA1859@swordfish>
Date:	Tue, 7 Apr 2015 10:56:56 +0900
From:	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
To:	akpm@...ux-foundation.org
Cc:	Julia.Lawall@...6.fr, minchan@...nel.org, ngupta@...are.org,
	mm-commits@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: + zram-fix-error-return-code.patch added to -mm tree

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

good catch.
Acked-by: Sergey Senozhatsky <sergey.senozhatsky.work@...il.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 majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ