summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/u_f.c
diff options
context:
space:
mode:
authorFelipe F. Tonello <eu@felipetonello.com>2016-08-08 21:30:06 +0100
committerFelipe Balbi <felipe.balbi@linux.intel.com>2016-08-25 12:13:14 +0300
commite0466156ee2e944fb47a3fa00932c3698a6d2c67 (patch)
treef947729434d5042df8ebeb2ca86def77ec67fa9f /drivers/usb/gadget/u_f.c
parent69bb99738b5c6d56d2b1a75db9cbb4d187453c1a (diff)
usb: gadget: align buffer size when allocating for OUT endpoint
Using usb_ep_align() makes sure that the buffer size for OUT endpoints is always aligned with wMaxPacketSize (512 usually). This makes sure that no buffer has the wrong size, which can cause nasty bugs. Signed-off-by: Felipe F. Tonello <eu@felipetonello.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb/gadget/u_f.c')
-rw-r--r--drivers/usb/gadget/u_f.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/gadget/u_f.c b/drivers/usb/gadget/u_f.c
index 6811761fec64..907f8144813c 100644
--- a/drivers/usb/gadget/u_f.c
+++ b/drivers/usb/gadget/u_f.c
@@ -12,6 +12,7 @@
*/
#include "u_f.h"
+#include <linux/usb/ch9.h>
struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len, int default_len)
{
@@ -20,6 +21,8 @@ struct usb_request *alloc_ep_req(struct usb_ep *ep, size_t len, int default_len)
req = usb_ep_alloc_request(ep, GFP_ATOMIC);
if (req) {
req->length = len ?: default_len;
+ if (usb_endpoint_dir_out(ep->desc))
+ req->length = usb_ep_align(ep, req->length);
req->buf = kmalloc(req->length, GFP_ATOMIC);
if (!req->buf) {
usb_ep_free_request(ep, req);