All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: evdev - Fix incorrect kfree of err_free_client after vzalloc
@ 2014-06-12  1:45 Yongtaek Lee
  2014-06-12  6:49 ` David Rientjes
  2014-06-20 14:14 ` David Herrmann
  0 siblings, 2 replies; 4+ messages in thread
From: Yongtaek Lee @ 2014-06-12  1:45 UTC (permalink / raw)
  To: rydberg, dmitry.torokhov, daniels; +Cc: linux-input, linux-kernel, ytk.lee

This bug was introduced by commit 92eb77d ("Input: evdev - fall back
to vmalloc for client event buffer").

vzalloc is used to alloc memory as fallback in case of failure
of kzalloc. But err_free_client was not considered on below case.
1. kzalloc fail
2. vzalloc success
3. evdev_open_device fail
4. kfree

So that address checking is needed to call correct free function.

Signed-off-by: Yongtaek Lee <ytk.lee@samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
---
 drivers/input/evdev.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index ce953d8..f60daa0 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -422,7 +422,10 @@ static int evdev_open(struct inode *inode, struct file *file)
 
  err_free_client:
 	evdev_detach_client(evdev, client);
-	kfree(client);
+	if (is_vmalloc_addr(client))
+		vfree(client);
+	else
+		kfree(client);
 	return error;
 }
 
-- 
1.7.1


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

* Re: [PATCH] Input: evdev - Fix incorrect kfree of err_free_client after vzalloc
  2014-06-12  1:45 [PATCH] Input: evdev - Fix incorrect kfree of err_free_client after vzalloc Yongtaek Lee
@ 2014-06-12  6:49 ` David Rientjes
  2014-06-20 14:14 ` David Herrmann
  1 sibling, 0 replies; 4+ messages in thread
From: David Rientjes @ 2014-06-12  6:49 UTC (permalink / raw)
  To: Yongtaek Lee; +Cc: rydberg, dmitry.torokhov, daniels, linux-input, linux-kernel

On Thu, 12 Jun 2014, Yongtaek Lee wrote:

> This bug was introduced by commit 92eb77d ("Input: evdev - fall back
> to vmalloc for client event buffer").
> 
> vzalloc is used to alloc memory as fallback in case of failure
> of kzalloc. But err_free_client was not considered on below case.
> 1. kzalloc fail
> 2. vzalloc success
> 3. evdev_open_device fail
> 4. kfree
> 
> So that address checking is needed to call correct free function.
> 
> Signed-off-by: Yongtaek Lee <ytk.lee@samsung.com>
> Reviewed-by: Daniel Stone <daniels@collabora.com>

Acked-by: David Rientjes <rientjes@google.com>

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

* Re: [PATCH] Input: evdev - Fix incorrect kfree of err_free_client after vzalloc
  2014-06-12  1:45 [PATCH] Input: evdev - Fix incorrect kfree of err_free_client after vzalloc Yongtaek Lee
  2014-06-12  6:49 ` David Rientjes
@ 2014-06-20 14:14 ` David Herrmann
  2014-06-23  1:12   ` Yongtaek Lee
  1 sibling, 1 reply; 4+ messages in thread
From: David Herrmann @ 2014-06-20 14:14 UTC (permalink / raw)
  To: Yongtaek Lee
  Cc: Henrik Rydberg, Dmitry Torokhov, daniels,
	open list:HID CORE LAYER, linux-kernel

Hi

On Thu, Jun 12, 2014 at 3:45 AM, Yongtaek Lee <ytk.lee@samsung.com> wrote:
> This bug was introduced by commit 92eb77d ("Input: evdev - fall back
> to vmalloc for client event buffer").
>
> vzalloc is used to alloc memory as fallback in case of failure
> of kzalloc. But err_free_client was not considered on below case.
> 1. kzalloc fail
> 2. vzalloc success
> 3. evdev_open_device fail
> 4. kfree
>
> So that address checking is needed to call correct free function.
>
> Signed-off-by: Yongtaek Lee <ytk.lee@samsung.com>
> Reviewed-by: Daniel Stone <daniels@collabora.com>

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

Thanks
David

> ---
>  drivers/input/evdev.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
> index ce953d8..f60daa0 100644
> --- a/drivers/input/evdev.c
> +++ b/drivers/input/evdev.c
> @@ -422,7 +422,10 @@ static int evdev_open(struct inode *inode, struct file *file)
>
>   err_free_client:
>         evdev_detach_client(evdev, client);
> -       kfree(client);
> +       if (is_vmalloc_addr(client))
> +               vfree(client);
> +       else
> +               kfree(client);
>         return error;
>  }
>
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH] Input: evdev - Fix incorrect kfree of err_free_client after vzalloc
  2014-06-20 14:14 ` David Herrmann
@ 2014-06-23  1:12   ` Yongtaek Lee
  0 siblings, 0 replies; 4+ messages in thread
From: Yongtaek Lee @ 2014-06-23  1:12 UTC (permalink / raw)
  To: rydberg, dmitry.torokhov, daniels, rientjes, dh.herrmann
  Cc: linux-input, linux-kernel, Yongtaek Lee

This bug was introduced by commit 92eb77d ("Input: evdev - fall back
to vmalloc for client event buffer").

vzalloc is used to alloc memory as fallback in case of failure
of kzalloc. But err_free_client was not considered on below case.
1. kzalloc fail
2. vzalloc success
3. evdev_open_device fail
4. kfree

So that address checking is needed to call correct free function.

Signed-off-by: Yongtaek Lee <ytk.lee@samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: David Rientjes <rientjes@google.com>
---
 drivers/input/evdev.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index ce953d8..f60daa0 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -422,7 +422,10 @@ static int evdev_open(struct inode *inode, struct file *file)
 
  err_free_client:
 	evdev_detach_client(evdev, client);
-	kfree(client);
+	if (is_vmalloc_addr(client))
+		vfree(client);
+	else
+		kfree(client);
 	return error;
 }
 
-- 
1.7.1


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

end of thread, other threads:[~2014-06-23  1:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12  1:45 [PATCH] Input: evdev - Fix incorrect kfree of err_free_client after vzalloc Yongtaek Lee
2014-06-12  6:49 ` David Rientjes
2014-06-20 14:14 ` David Herrmann
2014-06-23  1:12   ` Yongtaek Lee

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.