Loading drivers/usb/gadget/composite.c +2 −1 Original line number Diff line number Diff line Loading @@ -2103,7 +2103,8 @@ int composite_dev_prepare(struct usb_composite_driver *composite, if (!cdev->req) return -ENOMEM; cdev->req->buf = kmalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL); cdev->req->buf = kmalloc(USB_COMP_EP0_BUFSIZ + (gadget->extra_buf_alloc), GFP_KERNEL); if (!cdev->req->buf) goto fail; Loading drivers/usb/gadget/function/f_accessory.c +2 −1 Original line number Diff line number Diff line Loading @@ -579,7 +579,8 @@ static int create_bulk_endpoints(struct acc_dev *dev, /* now allocate requests for our endpoints */ for (i = 0; i < TX_REQ_MAX; i++) { req = acc_request_new(dev->ep_in, BULK_BUFFER_SIZE); req = acc_request_new(dev->ep_in, BULK_BUFFER_SIZE + cdev->gadget->extra_buf_alloc); if (!req) goto fail; req->complete = acc_complete_in; Loading drivers/usb/gadget/function/f_acm.c +1 −1 Original line number Diff line number Diff line Loading @@ -788,7 +788,7 @@ acm_bind(struct usb_configuration *c, struct usb_function *f) /* allocate notification */ acm->notify_req = gs_alloc_req(ep, sizeof(struct usb_cdc_notification) + 2, GFP_KERNEL); cdev->gadget->extra_buf_alloc, GFP_KERNEL); if (!acm->notify_req) goto fail; Loading drivers/usb/gadget/function/f_fs.c +24 −6 Original line number Diff line number Diff line Loading @@ -189,7 +189,8 @@ static void ffs_closed(struct ffs_data *ffs); static int ffs_mutex_lock(struct mutex *mutex, unsigned nonblock) __attribute__((warn_unused_result, nonnull)); static char *ffs_prepare_buffer(const char __user *buf, size_t len) static char *ffs_prepare_buffer(const char __user *buf, size_t len, size_t extra_buf_alloc) __attribute__((warn_unused_result, nonnull)); Loading Loading @@ -255,6 +256,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf, size_t len, loff_t *ptr) { struct ffs_data *ffs = file->private_data; struct usb_gadget *gadget = ffs->gadget; ssize_t ret; char *data; Loading @@ -279,7 +281,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf, break; } data = ffs_prepare_buffer(buf, len); data = ffs_prepare_buffer(buf, len, 0); if (IS_ERR(data)) { ret = PTR_ERR(data); break; Loading Loading @@ -352,7 +354,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf, spin_unlock_irq(&ffs->ev.waitq.lock); data = ffs_prepare_buffer(buf, len); data = ffs_prepare_buffer(buf, len, gadget->extra_buf_alloc); if (IS_ERR(data)) { ret = PTR_ERR(data); break; Loading Loading @@ -711,9 +713,11 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) { struct ffs_epfile *epfile = file->private_data; struct ffs_ep *ep; struct ffs_data *ffs = epfile->ffs; char *data = NULL; ssize_t ret, data_len = -EINVAL; int halt; size_t extra_buf_alloc = 0; pr_debug("%s: len %zu, read %d\n", __func__, io_data->len, io_data->read); Loading Loading @@ -787,6 +791,11 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) io_data->len; spin_unlock_irq(&epfile->ffs->eps_lock); extra_buf_alloc = ffs->gadget->extra_buf_alloc; if (io_data->read) data = kmalloc(data_len + extra_buf_alloc, GFP_KERNEL); else data = kmalloc(data_len, GFP_KERNEL); if (unlikely(!data)) return -ENOMEM; Loading Loading @@ -3557,14 +3566,23 @@ static int ffs_mutex_lock(struct mutex *mutex, unsigned nonblock) : mutex_lock_interruptible(mutex); } static char *ffs_prepare_buffer(const char __user *buf, size_t len) /** * ffs_prepare_buffer() - copy userspace buffer into kernel. * @buf: userspace buffer * @len: length of the buffer * @extra_alloc_buf: Extra buffer allocation if required by UDC. * * This function returns pointer to the copied buffer */ static char *ffs_prepare_buffer(const char __user *buf, size_t len, size_t extra_buf_alloc) { char *data; if (unlikely(!len)) return NULL; data = kmalloc(len, GFP_KERNEL); data = kmalloc(len + extra_buf_alloc, GFP_KERNEL); if (unlikely(!data)) return ERR_PTR(-ENOMEM); Loading drivers/usb/gadget/function/f_mtp.c +5 −2 Original line number Diff line number Diff line Loading @@ -515,6 +515,7 @@ static int mtp_create_bulk_endpoints(struct mtp_dev *dev, struct usb_composite_dev *cdev = dev->cdev; struct usb_request *req; struct usb_ep *ep; size_t extra_buf_alloc = cdev->gadget->extra_buf_alloc; int i; DBG(cdev, "create_bulk_endpoints dev: %p\n", dev); Loading Loading @@ -552,7 +553,8 @@ retry_tx_alloc: /* now allocate requests for our endpoints */ for (i = 0; i < mtp_tx_reqs; i++) { req = mtp_request_new(dev->ep_in, mtp_tx_req_len); req = mtp_request_new(dev->ep_in, mtp_tx_req_len + extra_buf_alloc); if (!req) { if (mtp_tx_req_len <= MTP_BULK_BUFFER_SIZE) goto fail; Loading Loading @@ -590,7 +592,8 @@ retry_rx_alloc: dev->rx_req[i] = req; } for (i = 0; i < INTR_REQ_MAX; i++) { req = mtp_request_new(dev->ep_intr, INTR_BUFFER_SIZE); req = mtp_request_new(dev->ep_intr, INTR_BUFFER_SIZE + extra_buf_alloc); if (!req) goto fail; req->complete = mtp_complete_intr; Loading Loading
drivers/usb/gadget/composite.c +2 −1 Original line number Diff line number Diff line Loading @@ -2103,7 +2103,8 @@ int composite_dev_prepare(struct usb_composite_driver *composite, if (!cdev->req) return -ENOMEM; cdev->req->buf = kmalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL); cdev->req->buf = kmalloc(USB_COMP_EP0_BUFSIZ + (gadget->extra_buf_alloc), GFP_KERNEL); if (!cdev->req->buf) goto fail; Loading
drivers/usb/gadget/function/f_accessory.c +2 −1 Original line number Diff line number Diff line Loading @@ -579,7 +579,8 @@ static int create_bulk_endpoints(struct acc_dev *dev, /* now allocate requests for our endpoints */ for (i = 0; i < TX_REQ_MAX; i++) { req = acc_request_new(dev->ep_in, BULK_BUFFER_SIZE); req = acc_request_new(dev->ep_in, BULK_BUFFER_SIZE + cdev->gadget->extra_buf_alloc); if (!req) goto fail; req->complete = acc_complete_in; Loading
drivers/usb/gadget/function/f_acm.c +1 −1 Original line number Diff line number Diff line Loading @@ -788,7 +788,7 @@ acm_bind(struct usb_configuration *c, struct usb_function *f) /* allocate notification */ acm->notify_req = gs_alloc_req(ep, sizeof(struct usb_cdc_notification) + 2, GFP_KERNEL); cdev->gadget->extra_buf_alloc, GFP_KERNEL); if (!acm->notify_req) goto fail; Loading
drivers/usb/gadget/function/f_fs.c +24 −6 Original line number Diff line number Diff line Loading @@ -189,7 +189,8 @@ static void ffs_closed(struct ffs_data *ffs); static int ffs_mutex_lock(struct mutex *mutex, unsigned nonblock) __attribute__((warn_unused_result, nonnull)); static char *ffs_prepare_buffer(const char __user *buf, size_t len) static char *ffs_prepare_buffer(const char __user *buf, size_t len, size_t extra_buf_alloc) __attribute__((warn_unused_result, nonnull)); Loading Loading @@ -255,6 +256,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf, size_t len, loff_t *ptr) { struct ffs_data *ffs = file->private_data; struct usb_gadget *gadget = ffs->gadget; ssize_t ret; char *data; Loading @@ -279,7 +281,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf, break; } data = ffs_prepare_buffer(buf, len); data = ffs_prepare_buffer(buf, len, 0); if (IS_ERR(data)) { ret = PTR_ERR(data); break; Loading Loading @@ -352,7 +354,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char __user *buf, spin_unlock_irq(&ffs->ev.waitq.lock); data = ffs_prepare_buffer(buf, len); data = ffs_prepare_buffer(buf, len, gadget->extra_buf_alloc); if (IS_ERR(data)) { ret = PTR_ERR(data); break; Loading Loading @@ -711,9 +713,11 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) { struct ffs_epfile *epfile = file->private_data; struct ffs_ep *ep; struct ffs_data *ffs = epfile->ffs; char *data = NULL; ssize_t ret, data_len = -EINVAL; int halt; size_t extra_buf_alloc = 0; pr_debug("%s: len %zu, read %d\n", __func__, io_data->len, io_data->read); Loading Loading @@ -787,6 +791,11 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) io_data->len; spin_unlock_irq(&epfile->ffs->eps_lock); extra_buf_alloc = ffs->gadget->extra_buf_alloc; if (io_data->read) data = kmalloc(data_len + extra_buf_alloc, GFP_KERNEL); else data = kmalloc(data_len, GFP_KERNEL); if (unlikely(!data)) return -ENOMEM; Loading Loading @@ -3557,14 +3566,23 @@ static int ffs_mutex_lock(struct mutex *mutex, unsigned nonblock) : mutex_lock_interruptible(mutex); } static char *ffs_prepare_buffer(const char __user *buf, size_t len) /** * ffs_prepare_buffer() - copy userspace buffer into kernel. * @buf: userspace buffer * @len: length of the buffer * @extra_alloc_buf: Extra buffer allocation if required by UDC. * * This function returns pointer to the copied buffer */ static char *ffs_prepare_buffer(const char __user *buf, size_t len, size_t extra_buf_alloc) { char *data; if (unlikely(!len)) return NULL; data = kmalloc(len, GFP_KERNEL); data = kmalloc(len + extra_buf_alloc, GFP_KERNEL); if (unlikely(!data)) return ERR_PTR(-ENOMEM); Loading
drivers/usb/gadget/function/f_mtp.c +5 −2 Original line number Diff line number Diff line Loading @@ -515,6 +515,7 @@ static int mtp_create_bulk_endpoints(struct mtp_dev *dev, struct usb_composite_dev *cdev = dev->cdev; struct usb_request *req; struct usb_ep *ep; size_t extra_buf_alloc = cdev->gadget->extra_buf_alloc; int i; DBG(cdev, "create_bulk_endpoints dev: %p\n", dev); Loading Loading @@ -552,7 +553,8 @@ retry_tx_alloc: /* now allocate requests for our endpoints */ for (i = 0; i < mtp_tx_reqs; i++) { req = mtp_request_new(dev->ep_in, mtp_tx_req_len); req = mtp_request_new(dev->ep_in, mtp_tx_req_len + extra_buf_alloc); if (!req) { if (mtp_tx_req_len <= MTP_BULK_BUFFER_SIZE) goto fail; Loading Loading @@ -590,7 +592,8 @@ retry_rx_alloc: dev->rx_req[i] = req; } for (i = 0; i < INTR_REQ_MAX; i++) { req = mtp_request_new(dev->ep_intr, INTR_BUFFER_SIZE); req = mtp_request_new(dev->ep_intr, INTR_BUFFER_SIZE + extra_buf_alloc); if (!req) goto fail; req->complete = mtp_complete_intr; Loading