]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Input: mousedev - fix memory leak
authorKimball Murray <kimball.murray@stratus.com>
Thu, 2 Feb 2006 05:08:59 +0000 (00:08 -0500)
committerChris Wright <chrisw@sous-sol.org>
Fri, 10 Feb 2006 07:20:07 +0000 (23:20 -0800)
Input: mousedev - fix memory leak

Apparently, "while true; do cat </dev/null >/dev/input/mice; done" causes
an OOM in a short amount of time. Funny that nobody noticed, it actually
is very easy to trigger just by switching between VT1 and VT7...

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/input/mousedev.c

index 2d0af44ac4b9650871972e6af74cf4ff2771a2b0..b329f10f970f8057783ab942e967007187f4aca8 100644 (file)
@@ -356,7 +356,7 @@ static void mousedev_free(struct mousedev *mousedev)
        kfree(mousedev);
 }
 
-static int mixdev_release(void)
+static void mixdev_release(void)
 {
        struct input_handle *handle;
 
@@ -370,8 +370,6 @@ static int mixdev_release(void)
                                mousedev_free(mousedev);
                }
        }
-
-       return 0;
 }
 
 static int mousedev_release(struct inode * inode, struct file * file)
@@ -384,9 +382,8 @@ static int mousedev_release(struct inode * inode, struct file * file)
 
        if (!--list->mousedev->open) {
                if (list->mousedev->minor == MOUSEDEV_MIX)
-                       return mixdev_release();
-
-               if (!mousedev_mix.open) {
+                       mixdev_release();
+               else if (!mousedev_mix.open) {
                        if (list->mousedev->exist)
                                input_close_device(&list->mousedev->handle);
                        else