* [PATCH] Input: evdev: correct handling of memory allocation failure of evdev_client
@ 2016-01-25 17:50 Aniroop Mathur
2016-01-27 23:42 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Aniroop Mathur @ 2016-01-25 17:50 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: linux-input, linux-kernel, aniroop.mathur, Aniroop Mathur
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] Input: evdev: correct handling of memory allocation failure of evdev_client
2016-01-25 17:50 [PATCH] Input: evdev: correct handling of memory allocation failure of evdev_client Aniroop Mathur
@ 2016-01-27 23:42 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2016-01-27 23:42 UTC (permalink / raw)
To: Aniroop Mathur; +Cc: linux-input, linux-kernel, aniroop.mathur
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-01-27 23:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-25 17:50 [PATCH] Input: evdev: correct handling of memory allocation failure of evdev_client Aniroop Mathur
2016-01-27 23:42 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).