Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1317123 > unrolled thread

[PATCH] Input: evdev: correct handling of memory allocation failure of evdev_client

Started byAniroop Mathur <a.mathur@samsung.com>
First post2016-01-25 18:50 +0100
Last post2016-01-28 00:50 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] Input: evdev: correct handling of memory allocation failure of evdev_client Aniroop Mathur <a.mathur@samsung.com> - 2016-01-25 18:50 +0100
    Re: [PATCH] Input: evdev: correct handling of memory allocation  failure of evdev_client Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2016-01-28 00:50 +0100

#1317123 — [PATCH] Input: evdev: correct handling of memory allocation failure of evdev_client

FromAniroop Mathur <a.mathur@samsung.com>
Date2016-01-25 18:50 +0100
Subject[PATCH] Input: evdev: correct handling of memory allocation failure of evdev_client
Message-ID<qUTr3-7vm-5@gated-at.bofh.it>
Lets fix twice checking of memory allocation failure of evdev_client
structure when allocated successfully.

Signed-off-by: Aniroop Mathur <a.mathur@samsung.com>
---
 drivers/input/evdev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index e9ae3d5..102b5d9 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -503,10 +503,11 @@ static int evdev_open(struct inode *inode, struct file *file)
 	int error;
 
 	client = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
-	if (!client)
+	if (!client) {
 		client = vzalloc(size);
-	if (!client)
-		return -ENOMEM;
+		if (!client)
+			return -ENOMEM;
+	}
 
 	client->bufsize = bufsize;
 	spin_lock_init(&client->buffer_lock);
-- 
2.6.2

[toc] | [next] | [standalone]


#1320148 — Re: [PATCH] Input: evdev: correct handling of memory allocation failure of evdev_client

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2016-01-28 00:50 +0100
SubjectRe: [PATCH] Input: evdev: correct handling of memory allocation failure of evdev_client
Message-ID<qVI0x-2V1-1@gated-at.bofh.it>
In reply to#1317123
Hi Aniroop,

On Mon, Jan 25, 2016 at 11:20:05PM +0530, Aniroop Mathur wrote:
> Lets fix twice checking of memory allocation failure of evdev_client
> structure when allocated successfully.

I think compiler will take care of optimizing away the 2nd check, so I'd
leave the code as is.

Thanks.

> 
> Signed-off-by: Aniroop Mathur <a.mathur@samsung.com>
> ---
>  drivers/input/evdev.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
> index e9ae3d5..102b5d9 100644
> --- a/drivers/input/evdev.c
> +++ b/drivers/input/evdev.c
> @@ -503,10 +503,11 @@ static int evdev_open(struct inode *inode, struct file *file)
>  	int error;
>  
>  	client = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
> -	if (!client)
> +	if (!client) {
>  		client = vzalloc(size);
> -	if (!client)
> -		return -ENOMEM;
> +		if (!client)
> +			return -ENOMEM;
> +	}
>  
>  	client->bufsize = bufsize;
>  	spin_lock_init(&client->buffer_lock);
> -- 
> 2.6.2
> 

-- 
Dmitry

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web