Skip to content

Commit

Permalink
xhci: handle failed buffer copy to URB sg list and fix a W=1 copiler …
Browse files Browse the repository at this point in the history
…warning

[ Upstream commit 271a21d ]

Set the urb->actual_length to bytes successfully copied in case all bytes
weren't copied from a temporary buffer to the URB sg list.
Also print a debug message

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20210617150354.1512157-4-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
matnyman authored and gregkh committed Jul 20, 2021
1 parent a35f81d commit 91ab5c6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/usb/host/xhci.c
Expand Up @@ -1362,12 +1362,17 @@ static void xhci_unmap_temp_buf(struct usb_hcd *hcd, struct urb *urb)
urb->transfer_buffer_length,
dir);

if (usb_urb_dir_in(urb))
if (usb_urb_dir_in(urb)) {
len = sg_pcopy_from_buffer(urb->sg, urb->num_sgs,
urb->transfer_buffer,
buf_len,
0);

if (len != buf_len) {
xhci_dbg(hcd_to_xhci(hcd),
"Copy from tmp buf to urb sg list failed\n");
urb->actual_length = len;
}
}
urb->transfer_flags &= ~URB_DMA_MAP_SINGLE;
kfree(urb->transfer_buffer);
urb->transfer_buffer = NULL;
Expand Down

0 comments on commit 91ab5c6

Please sign in to comment.