aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHavard Skinnemoen <hskinnemoen@google.com>2012-04-26 14:16:00 -0400
committerJiri Kosina <jkosina@suse.cz>2012-04-27 10:03:40 -0400
commitd4f0e4daf0d867f80c78ca4f9ac03a562e229e72 (patch)
tree2a370bb114f8d4e1a66a69f7d3dcdcef3cc3b716
parent9f1f463ae5d8597fe2b4ffc73051616c47ac1924 (diff)
HID: hiddev: Use vzalloc to allocate hiddev_list
Everytime a HID device is opened, a new hiddev_list is allocated with kzalloc. This requires 64KB of physically contiguous memory, which could easily push a heavily loaded system over the edge. Allocating the same amount of memory with vmalloc shouldn't be nearly as demanding, so let's do that instead. The memory isn't used for DMA and doesn't look particularly performance sensitive, so this should be safe. Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/usbhid/hiddev.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index b1ec0e2aeb57..14599e256791 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -34,6 +34,7 @@
34#include <linux/hid.h> 34#include <linux/hid.h>
35#include <linux/hiddev.h> 35#include <linux/hiddev.h>
36#include <linux/compat.h> 36#include <linux/compat.h>
37#include <linux/vmalloc.h>
37#include "usbhid.h" 38#include "usbhid.h"
38 39
39#ifdef CONFIG_USB_DYNAMIC_MINORS 40#ifdef CONFIG_USB_DYNAMIC_MINORS
@@ -250,13 +251,13 @@ static int hiddev_release(struct inode * inode, struct file * file)
250 } else { 251 } else {
251 mutex_unlock(&list->hiddev->existancelock); 252 mutex_unlock(&list->hiddev->existancelock);
252 kfree(list->hiddev); 253 kfree(list->hiddev);
253 kfree(list); 254 vfree(list);
254 return 0; 255 return 0;
255 } 256 }
256 } 257 }
257 258
258 mutex_unlock(&list->hiddev->existancelock); 259 mutex_unlock(&list->hiddev->existancelock);
259 kfree(list); 260 vfree(list);
260 261
261 return 0; 262 return 0;
262} 263}
@@ -278,7 +279,7 @@ static int hiddev_open(struct inode *inode, struct file *file)
278 hid = usb_get_intfdata(intf); 279 hid = usb_get_intfdata(intf);
279 hiddev = hid->hiddev; 280 hiddev = hid->hiddev;
280 281
281 if (!(list = kzalloc(sizeof(struct hiddev_list), GFP_KERNEL))) 282 if (!(list = vzalloc(sizeof(struct hiddev_list))))
282 return -ENOMEM; 283 return -ENOMEM;
283 mutex_init(&list->thread_lock); 284 mutex_init(&list->thread_lock);
284 list->hiddev = hiddev; 285 list->hiddev = hiddev;
@@ -322,7 +323,7 @@ bail_unlock:
322 mutex_unlock(&hiddev->existancelock); 323 mutex_unlock(&hiddev->existancelock);
323bail: 324bail:
324 file->private_data = NULL; 325 file->private_data = NULL;
325 kfree(list); 326 vfree(list);
326 return res; 327 return res;
327} 328}
328 329