mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-01 06:33:07 +00:00
usb: xhci: Add error handling in xhci_map_urb_for_dma
[ Upstream commitbe95cc6d71
] Currently xhci_map_urb_for_dma() creates a temporary buffer and copies the SG list to the new linear buffer. But if the kzalloc_node() fails, then the following sg_pcopy_to_buffer() can lead to crash since it tries to memcpy to NULL pointer. So return -ENOMEM if kzalloc returns null pointer. Cc: stable@vger.kernel.org # 5.11 Fixes:2017a1e584
("usb: xhci: Use temporary buffer to consolidate SG") Signed-off-by: Prashanth K <quic_prashk@quicinc.com> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20240229141438.619372-10-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
537040c257
commit
b2c898469d
1 changed files with 2 additions and 0 deletions
|
@ -1334,6 +1334,8 @@ static int xhci_map_temp_buffer(struct usb_hcd *hcd, struct urb *urb)
|
||||||
|
|
||||||
temp = kzalloc_node(buf_len, GFP_ATOMIC,
|
temp = kzalloc_node(buf_len, GFP_ATOMIC,
|
||||||
dev_to_node(hcd->self.sysdev));
|
dev_to_node(hcd->self.sysdev));
|
||||||
|
if (!temp)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
if (usb_urb_dir_out(urb))
|
if (usb_urb_dir_out(urb))
|
||||||
sg_pcopy_to_buffer(urb->sg, urb->num_sgs,
|
sg_pcopy_to_buffer(urb->sg, urb->num_sgs,
|
||||||
|
|
Loading…
Reference in a new issue