Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ca9a321 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman
Browse files

USB: musb: fix inefficient copy of unaligned buffers



Make sure only to copy any actual data rather than the whole buffer,
when releasing the temporary buffer used for unaligned non-isochronous
transfers.

Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a8425292
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -2512,6 +2512,7 @@ static void musb_free_temp_buffer(struct urb *urb)
{
{
	enum dma_data_direction dir;
	enum dma_data_direction dir;
	struct musb_temp_buffer *temp;
	struct musb_temp_buffer *temp;
	size_t length;


	if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER))
	if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER))
		return;
		return;
@@ -2522,8 +2523,12 @@ static void musb_free_temp_buffer(struct urb *urb)
			    data);
			    data);


	if (dir == DMA_FROM_DEVICE) {
	if (dir == DMA_FROM_DEVICE) {
		memcpy(temp->old_xfer_buffer, temp->data,
		if (usb_pipeisoc(urb->pipe))
		       urb->transfer_buffer_length);
			length = urb->transfer_buffer_length;
		else
			length = urb->actual_length;

		memcpy(temp->old_xfer_buffer, temp->data, length);
	}
	}
	urb->transfer_buffer = temp->old_xfer_buffer;
	urb->transfer_buffer = temp->old_xfer_buffer;
	kfree(temp->kmalloc_ptr);
	kfree(temp->kmalloc_ptr);