Input: evdev: correct handling of memory allocation failure of evdev_client
Subsystems (2)
PATCH 1/1 Input: evdev: correct handling of memory allocation failure of evdev_client
Lets fix twice checking of memory allocation failure of evdev_client structure when allocated successfully.
Signed-off-by Aniroop Mathur <[email protected]>
--- drivers/input/evdev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/input/evdev.c +4 -3
@@ -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);
Signature · 1 line
2.6.2
Dmitry Torokhov
maintainerHi Aniroop,
Quoted 2 lines · Aniroop Mathur
Lets fix twice checking of memory allocation failure of
evdev_clientstructure when allocated successfully.
I think compiler will take care of optimizing away the 2nd check, so I'd leave the code as is.
Thanks.
Quoted 28 lines
Signed-off-by Aniroop Mathur <[email protected]>--- drivers/input/evdev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/input/evdev.c +4
-3@@ -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);Signature · 1 line
2.6.2
Signature · 1 line
Dmitry