Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2481419pxj; Mon, 10 May 2021 04:08:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDlgPR8a4IXrc299vyTdecFcabnIf3+K9QCM2Mi8vmU27bUaqVxcaJbebhGDDUh0o0SXM3 X-Received: by 2002:a17:906:90b:: with SMTP id i11mr25025868ejd.168.1620644926641; Mon, 10 May 2021 04:08:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620644926; cv=none; d=google.com; s=arc-20160816; b=TC9tBgmEfaNLoEFJP77u4qdBw84QVoeXoys0k/fSZ6mIsLTwsD75nuR7feZXtm+58l IA/lgT1z9fWtofBJTdzlxrLGL26aAZc2OHsKopwayAjn7RUVuSD5akGk+H5BNo4iDwa3 PYezZV4cfWBYhXTlqR90vjQ1lz1DisWBACL+tV7Pl5cE9mgHEzIefvH1Vwk3vb7KDq0T nimeXuhBKNhgOnFDms1HTuCqdwbVCSvAZ6TshEGdTKA1WptcKXVU/YffG6XnuEQNE4r+ NA7scmKH8m4CEbePXQShKEOFWihPbzulwmySO3MxxGgp9KQDdJitHRfOYGa/P6VbecVJ nfrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6S5716OI3RlT4LYzYkBPG3FQBba25E8kvs6pgsDpIWs=; b=EV9Pihhz9pHldmO8/WQs0ddvsKdlP0xIcjMlT/dU/g29jIYg9HTzCtdps/xoOHU7RD /NkrP340O0MOCnOQXKINMW3dvby0uj9iZR87hB/h2A6s8vTzxLnblX3R2JwI9H4S4GET s0vCDmLc/2yGvN8PGIofbLrnqwTXnTMP32yhzl7SBWI5jxnz4G8rfE5kCKZJWGlhwy8v whZ0gZrwJVClnCtgITFbmie6H1YOM3dG6MfYwoONENLyTkRFSfNhCHa2v2eRJnblYHr1 52XYYDwHPAY+kUSRHR9hKiq5VSChuAxlNZPgyE9eyscJQCpCZwW+pa9LqgbXcuHTh4G2 Xy9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZgU7cPPy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qn11si13145380ejb.727.2021.05.10.04.08.19; Mon, 10 May 2021 04:08:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZgU7cPPy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232073AbhEJLDc (ORCPT + 99 others); Mon, 10 May 2021 07:03:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:59618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233322AbhEJKpg (ORCPT ); Mon, 10 May 2021 06:45:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B93256199E; Mon, 10 May 2021 10:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642961; bh=whyFaAlnwnzms0kmPscrjuOUj5e4DfyjYwtoS7ROKJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZgU7cPPycLFUCPdzQkiAfGtya33Rrdyws+OVnWJ5NEuhDrNNhaXqbWYT6Cu9Vc97i TSay5VNRVFY5gh8nQcLON5LeIoJoP67ZNBlM0U9BS/IuEcNynAphDpH522IhWrSYhY jwv0kiljNk8vJJQg72mcoJjVWh7ba65OZWpKG0u8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathias Nyman , Sasha Levin Subject: [PATCH 5.10 086/299] xhci: check control context is valid before dereferencing it. Date: Mon, 10 May 2021 12:18:03 +0200 Message-Id: <20210510102007.789233667@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathias Nyman [ Upstream commit 597899d2f7c5619c87185ee7953d004bd37fd0eb ] Don't dereference ctrl_ctx before checking it's valid. Issue reported by Klockwork Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20210406070208.3406266-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/xhci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index c449de6164b1..384076e169f4 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3227,6 +3227,14 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd, /* config ep command clears toggle if add and drop ep flags are set */ ctrl_ctx = xhci_get_input_control_ctx(cfg_cmd->in_ctx); + if (!ctrl_ctx) { + spin_unlock_irqrestore(&xhci->lock, flags); + xhci_free_command(xhci, cfg_cmd); + xhci_warn(xhci, "%s: Could not get input context, bad type.\n", + __func__); + goto cleanup; + } + xhci_setup_input_ctx_for_config_ep(xhci, cfg_cmd->in_ctx, vdev->out_ctx, ctrl_ctx, ep_flag, ep_flag); xhci_endpoint_copy(xhci, cfg_cmd->in_ctx, vdev->out_ctx, ep_index); -- 2.30.2