From patchwork Fri Mar 22 07:47:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janne Grunau via B4 Relay X-Patchwork-Id: 1914735 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=EKTDlM0j; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V1Dv53hcKz1yWy for ; Fri, 22 Mar 2024 18:47:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E43D0881A4; Fri, 22 Mar 2024 08:47:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="EKTDlM0j"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3EAC5881A0; Fri, 22 Mar 2024 08:47:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3CA7288028 for ; Fri, 22 Mar 2024 08:47:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=devnull+j.jannau.net@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DE5C161378; Fri, 22 Mar 2024 07:47:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 8969FC43394; Fri, 22 Mar 2024 07:47:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711093638; bh=+tYFN6+QK3PUW/oMQcTV0dPiASQpRO0mELezzogU4Y0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=EKTDlM0jETrOTVGDut2K2vyTRbghQA0fcnBdCO+VI7dyRYqSMXdyF8eZRWm/iguME fdtAAc5YhNRwCDu9LzpbQMQILWyoqKZTpoWgka7NDPQnKlPRG5WdeZfy0DD6IEjEFI UQ+Ji/FDGV25WL/NR7tP8ZDbKPvArPcRJ04QJk1z7qaeflhpIxdGdAFSIZfsHxLK75 +kQ8KcwY7E/WQ29fSnr1AsniFnT2ajNwCZSlGytlbXIZK6zJq9wwhA42Nb8+o9P0Ro xxsQx1sX2tlUPZXTgPT7R6S0lppqaC4US5AgW0kHcQSd/rNWEl6WSTTGqCSXaitfnc dMV4mXQUlTyOA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AEB5CD11DD; Fri, 22 Mar 2024 07:47:18 +0000 (UTC) From: Janne Grunau via B4 Relay Date: Fri, 22 Mar 2024 08:47:06 +0100 Subject: [PATCH v3 3/6] usb: xhci: Abort transfers with unallocated rings MIME-Version: 1.0 Message-Id: <20240322-asahi-keyboards-v3-3-3106dd4c4e19@jannau.net> References: <20240322-asahi-keyboards-v3-0-3106dd4c4e19@jannau.net> In-Reply-To: <20240322-asahi-keyboards-v3-0-3106dd4c4e19@jannau.net> To: Bin Meng , Marek Vasut , Tom Rini , Simon Glass , Joe Hershberger Cc: u-boot@lists.denx.de, asahi@lists.linux.dev, Janne Grunau , Neal Gompa X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1147; i=j@jannau.net; h=from:subject:message-id; bh=4WL/oK9QHrPZzv/LO0Lx0LR9aR1vioRk0nnmNOFZrzg=; b=owGbwMvMwCW2UNrmdq9+ahrjabUkhtS/5i0/Z//c82PbI5FnJ5J0P+bvktTYXRH4uW3yj+SbX M43/fxPdpSyMIhxMciKKbIkab/sYFhdoxhT+yAMZg4rE8gQBi5OAZjIrg0M/z39lHgOfdm0qued RyLfntM9h1kljY4miacsc9+wW/XsTzmGf9blPif0Wf95ztTvnz75MudElQal6c7J4uVrT78U2rh GghMA X-Developer-Key: i=j@jannau.net; a=openpgp; fpr=8B336A6BE4E5695E89B8532B81E806F586338419 X-Endpoint-Received: by B4 Relay for j@jannau.net/default with auth_id=62 X-Original-From: Janne Grunau X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: j@jannau.net Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Janne Grunau Discovered while trying to use the second interface in the USB keyboard driver necessary on Apple USB keyboards. Reviewed-by: Marek Vasut Reviewed-by: Neal Gompa Signed-off-by: Janne Grunau --- drivers/usb/host/xhci-ring.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index b60661fe05..910c5f3352 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -685,6 +685,9 @@ int xhci_bulk_tx(struct usb_device *udev, unsigned long pipe, reset_ep(udev, ep_index); ring = virt_dev->eps[ep_index].ring; + if (!ring) + return -EINVAL; + /* * How much data is (potentially) left before the 64KB boundary? * XHCI Spec puts restriction( TABLE 49 and 6.4.1 section of XHCI Spec) @@ -871,6 +874,8 @@ int xhci_ctrl_tx(struct usb_device *udev, unsigned long pipe, ep_index = usb_pipe_ep_index(pipe); ep_ring = virt_dev->eps[ep_index].ring; + if (!ep_ring) + return -EINVAL; /* * Check to see if the max packet size for the default control