Linux Input/HID development
 help / color / mirror / Atom feed
From: Yongtaek Lee <ytk.lee@samsung.com>
To: rydberg@euromail.se, dmitry.torokhov@gmail.com, daniels@collabora.com
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	ytk.lee@samsung.com
Subject: [PATCH] Input: evdev - Fix incorrect kfree of err_free_client after vzalloc
Date: Thu, 12 Jun 2014 10:45:37 +0900	[thread overview]
Message-ID: <1402537537-17945-1-git-send-email-ytk.lee@samsung.com> (raw)

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


             reply	other threads:[~2014-06-12  1:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-12  1:45 Yongtaek Lee [this message]
2014-06-12  6:49 ` [PATCH] Input: evdev - Fix incorrect kfree of err_free_client after vzalloc David Rientjes
2014-06-20 14:14 ` David Herrmann
2014-06-23  1:12   ` Yongtaek Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402537537-17945-1-git-send-email-ytk.lee@samsung.com \
    --to=ytk.lee@samsung.com \
    --cc=daniels@collabora.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rydberg@euromail.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox