]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.4.118/xhci-check-control-context-is-valid-before-dereferen.patch
Drop nfc patches from older trees
[thirdparty/kernel/stable-queue.git] / releases / 5.4.118 / xhci-check-control-context-is-valid-before-dereferen.patch
1 From d43fa5edb5a05c6f8278fc7e4c4dd6f1f4d3bf64 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Tue, 6 Apr 2021 10:02:06 +0300
4 Subject: xhci: check control context is valid before dereferencing it.
5
6 From: Mathias Nyman <mathias.nyman@linux.intel.com>
7
8 [ Upstream commit 597899d2f7c5619c87185ee7953d004bd37fd0eb ]
9
10 Don't dereference ctrl_ctx before checking it's valid.
11 Issue reported by Klockwork
12
13 Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
14 Link: https://lore.kernel.org/r/20210406070208.3406266-3-mathias.nyman@linux.intel.com
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
16 Signed-off-by: Sasha Levin <sashal@kernel.org>
17 ---
18 drivers/usb/host/xhci.c | 8 ++++++++
19 1 file changed, 8 insertions(+)
20
21 diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
22 index b5080bc1689e..143e4002e561 100644
23 --- a/drivers/usb/host/xhci.c
24 +++ b/drivers/usb/host/xhci.c
25 @@ -3227,6 +3227,14 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd,
26
27 /* config ep command clears toggle if add and drop ep flags are set */
28 ctrl_ctx = xhci_get_input_control_ctx(cfg_cmd->in_ctx);
29 + if (!ctrl_ctx) {
30 + spin_unlock_irqrestore(&xhci->lock, flags);
31 + xhci_free_command(xhci, cfg_cmd);
32 + xhci_warn(xhci, "%s: Could not get input context, bad type.\n",
33 + __func__);
34 + goto cleanup;
35 + }
36 +
37 xhci_setup_input_ctx_for_config_ep(xhci, cfg_cmd->in_ctx, vdev->out_ctx,
38 ctrl_ctx, ep_flag, ep_flag);
39 xhci_endpoint_copy(xhci, cfg_cmd->in_ctx, vdev->out_ctx, ep_index);
40 --
41 2.30.2
42