Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3401898pxb; Tue, 20 Apr 2021 07:34:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCj5eDb8TT6E3mNWiCTUR4rvP+EAEaJJVyE03kygP2rEskSjNs/Eb6+X7V8uQlARQ2iD5o X-Received: by 2002:a63:f34e:: with SMTP id t14mr17235364pgj.205.1618929292776; Tue, 20 Apr 2021 07:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618929292; cv=none; d=google.com; s=arc-20160816; b=p+EeT+sLw1WshnjX8ucs/TzBd8WWROi2q2u3GrZAmUbACj33WZeVPD7LiS+4PExyJf L8hifzzlYBeoDvkJ6hbQqp5BPKCViCiwn7UJ7KvjgbvTgD4rIJPBIG1QAKQ5FMHDTyhs 9zpqIKEwmXoAQ5qkGjvUbCPPUEuhHEIFIYB2ir0sInCOnj2PfOkddwgC/V2XSUb3F2CJ SEiU7mHsXlfRxc/3lm+Nltkom1JK1GEObvpl0Pa/U2Qj+Q/QgcT3vAxPj4VNnEnvpwka A9SosFBRwUH5hvxjpKvol6JmcWqjkeSjhnZaaVIkE91JzEh7HCVxrcGh9I2qLxbLj612 AXrA== 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 :message-id:date:subject:cc:to:from; bh=ybBuAIYG6oLwvk21sA5fh0Hjq012+f/SMSzfkW/XF3g=; b=t4sEk6/i0w8tmDkfXbcVg+6XPboMhCZhd1KJ6+uch84Lk+zUW29emz9sEOxaFbT9Kn PsGzpA9dYPOZGsUdc41k9Kl781PK+hHoeokTRfMx0cj4bTg9e4yyao+BK4i8bAGqsQxK jAZiW1HIRNWShWXxgfMpcvi5xPadzXBQomG1JezzlBHai5VjQTSLTdJC5hYLrVxDQwPx EIk+CbCMth1ENj98ijqkC9kXs+t3FUePquuwYIdyfzhcrHtR0o9N8gKd52kwpT4mq2jW G4Cwy54bwNyChUFu3tFacxu/7w3gdNfyyovvh9GI4H0fV7jb0HP9RaWwZnfCli33l+Qj u7Aw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h9si3460530pju.51.2021.04.20.07.34.39; Tue, 20 Apr 2021 07:34:52 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232597AbhDTOdS (ORCPT + 99 others); Tue, 20 Apr 2021 10:33:18 -0400 Received: from smtp02.smtpout.orange.fr ([80.12.242.124]:17541 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232450AbhDTOdR (ORCPT ); Tue, 20 Apr 2021 10:33:17 -0400 Received: from localhost.localdomain ([86.243.172.93]) by mwinf5d56 with ME id v2Yj2400321Fzsu032Yj4E; Tue, 20 Apr 2021 16:32:44 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 20 Apr 2021 16:32:44 +0200 X-ME-IP: 86.243.172.93 From: Christophe JAILLET To: mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH resend] xhci: Do not use GFP_KERNEL in (potentially) atomic context Date: Tue, 20 Apr 2021 14:32:23 +0200 Message-Id: X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'xhci_urb_enqueue()' is passed a 'mem_flags' argument, because "URBs may be submitted in interrupt context" (see comment related to 'usb_submit_urb()' in 'drivers/usb/core/urb.c') So this flag should be used in all the calling chain. Up to now, 'xhci_check_maxpacket()' which is only called from 'xhci_urb_enqueue()', uses GFP_KERNEL. Be safe and pass the mem_flags to this function as well. Fixes: ddba5cd0aeff ("xhci: Use command structures when queuing commands on the command ring") Signed-off-by: Christophe JAILLET --- I'm not 100% sure of the Fixes tag. The commit is the only that introduced this GFP_KERNEL, but I've not checked what was the behavior before that. If the patch is correct, I guess that a cc stable should be welcome. This patch was proposed on 14/08/20. It has been rebased on latest -next tree. --- drivers/usb/host/xhci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index ca9385d22f68..27283654ca08 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1514,7 +1514,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci, * we need to issue an evaluate context command and wait on it. */ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id, - unsigned int ep_index, struct urb *urb) + unsigned int ep_index, struct urb *urb, gfp_t mem_flags) { struct xhci_container_ctx *out_ctx; struct xhci_input_control_ctx *ctrl_ctx; @@ -1545,7 +1545,7 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id, * changes max packet sizes. */ - command = xhci_alloc_command(xhci, true, GFP_KERNEL); + command = xhci_alloc_command(xhci, true, mem_flags); if (!command) return -ENOMEM; @@ -1639,7 +1639,7 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag */ if (urb->dev->speed == USB_SPEED_FULL) { ret = xhci_check_maxpacket(xhci, slot_id, - ep_index, urb); + ep_index, urb, mem_flags); if (ret < 0) { xhci_urb_free_priv(urb_priv); urb->hcpriv = NULL; -- 2.27.0