usb: ks_bridge: Limit write size to 16KB
The user space application writes in 1MB chunks while loading MDM
images. The current code allocate as many bytes as user space
passed to write system call. These allocations are failing under
memory fragmentation scenario. Hence limit write size to 16KB.
CRs-Fixed: 434638
(cherry picked from commit 7fcc7799af7ace4c4eda229b0eac6448f98d6637)
Conflicts:
drivers/usb/misc/ks_bridge.c
Change-Id: I224cf201d724642f99e29874c4c5366ad773131e
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
diff --git a/drivers/usb/misc/ks_bridge.c b/drivers/usb/misc/ks_bridge.c
index 0b35f0d..ce50a99 100644
--- a/drivers/usb/misc/ks_bridge.c
+++ b/drivers/usb/misc/ks_bridge.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2012-2013, Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -284,6 +284,10 @@
unsigned long flags;
struct ks_bridge *ksb = fp->private_data;
+
+ if (count > MAX_DATA_PKT_SIZE)
+ count = MAX_DATA_PKT_SIZE;
+
pkt = ksb_alloc_data_pkt(count, GFP_KERNEL, ksb);
if (IS_ERR(pkt)) {
pr_err("unable to allocate data packet");