Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2453646rbb; Wed, 28 Feb 2024 02:12:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXj2N7K73qftYySADp4VQAcgKyAXWZV49HEhxXKaZ44ebZe7TW9y2Jw2WytKeV2oW2IAsl3/o2s0mWmtkWxiOOiqHmdMibbftDmd1Tb0w== X-Google-Smtp-Source: AGHT+IEQFpbd7IelGAH2gdLs1r6kkqpMnSO1rdlcexY6nGxKYpnbFaGWoUMpZ4rm3n89Z0siLj9b X-Received: by 2002:a05:6870:8314:b0:21e:5008:cf62 with SMTP id p20-20020a056870831400b0021e5008cf62mr15574933oae.21.1709115173392; Wed, 28 Feb 2024 02:12:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709115173; cv=pass; d=google.com; s=arc-20160816; b=NEipjvZHqFzg+yMKrIl3KJIgFdBRnQHiab9thiFGAm7a8EjaQhNyhCSJYDum9xREOm ueMeYhlYCDUv8S+Uu9OYcc7vqNdZ+xDX8MrZ1WtWglmmpZwqkKz8o+WD1l5xqb5P0JMb dm5McpsrJcsaYK0gIc0pUYjSpciPSgjq8IrmwxyG3EvcjpmllheH0dQerf3HoSTyXEbK 0Uri9anYHqZxRsqdAFE8abYDhsYyGhp4sfAqI4E6T48VrouW5Fwb7dfzsAAGdhjxm8Wy g0K2geuRZyBc25JpDhQy5JraomYYWOHNh5CqL0s4NrsWIZr9OJilUYN9evl+nf4IgAvh IE1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=eDhRFVyysNsDGN+FMhkZ93Dyyc7lx1J5zTtYdxW8Axo=; fh=t6x49ZWdKeqT23dsL92aPcRx24BQILKHiN2XfG1kXyc=; b=Q6jtq/rSbGiBDY/TBThNAX6rFD+/lI0r5YqaREbPpi8BfdymlgJ8VUu7k/BwKTgXGh h3OlWz4VEpZNmkCusCuF0Pkl/pTZ2k/FDXxRF1rwTEV6ELWxh8eOB3pSWXaoB3hPp8Eu zIT1SEgJ0hy0vWIy+g7ro0gTqZiDtrDgbrgYxwIJdEwTUuhFAosyVQNxbQMG49YmywDE FQCIm1EPe+pFXcx2feljX0fPnIvLH8wM3O42jij/a5Q+QOq+hyusX+ZGxInH6zMTVXmw cCgn8TE2QTyHMM2J9ffVoS5o5TWOo5Gb52hZwb04Op+6OMzRG5BNgjVNhDVb37/+XzID 67PA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=WF0LN4nb; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-84817-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84817-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c3-20020aa78e03000000b006e2861bc3f5si6967618pfr.38.2024.02.28.02.12.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 02:12:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84817-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=WF0LN4nb; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-84817-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84817-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AB79C2824B0 for ; Wed, 28 Feb 2024 10:12:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DAFDE381D2; Wed, 28 Feb 2024 10:12:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="WF0LN4nb" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A01BB3770C; Wed, 28 Feb 2024 10:12:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709115166; cv=none; b=X+YunkdejUYXkEJK5tuK6+NIhdQRIrHNDWAO+65lsgpw5c5t6aReu3eijrQ83+5qowVbK8TaxQN3j8TwV8mqHAcHavjJHi17ZmD13NMBROCz+YR2V20JW9ueOAwGT6WS7VHArE/DOz3ZLR/0Ubvhi1WN5vQCcGWlxdgskjX6qKM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709115166; c=relaxed/simple; bh=QtkybHA+dLfb/QVzUjDEIMZVXhkak6pmXpwwKXRPt+U=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=YKXp+wSetyphyUvgbel7FWbAys2ioYoAO9D6eU22qdQBO5QjNKwt+w5EWE4Z22215pxCGLX8UIpMm9g9ESJKUCJAX8zOt00Q8+1SVRjclmWgjwwbQoU7D1OReHlU/bxP/7418S/nUbzXhcjsGHKSx2vbJ9Y4hiDdrFfgJkPIKDU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=WF0LN4nb; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41S6KrNo022821; Wed, 28 Feb 2024 10:12:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=eDhRFVyysNsDGN+FMhkZ93Dyyc7lx1J5zTtYdxW8Axo=; b=WF 0LN4nbgJEokwn9Uy7ycFHIrs2p5K5ffHcwRvmYTkPvGD4dJbLxBsoK6RTAYrzXmd Nqfs46lrWE0UKe74b/7pVCs4cmx3hvcCj/JsPKJFYbK2yHnBChHuKYV+YNgFiF06 /rARxo03EqRQiQhkkusP0HP6RG9+hcmGzdy7nLQsKDlfM9Dq8factDCd7rHqcgzG jXL2sVE3o5keoYXWLs7adIKB9XX0e8gunHoTLPypCH0y5JP00nP8AL7FJap8cz4o cQ3Lan/zTSFD1akBS8TMvxZ6UicPtiVXljNNPlgl4QIwJzWsHQ26Up4PZQIx2mu5 LhfaWsLAnelcVth/1tVg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3whuksruj2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Feb 2024 10:12:41 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41SACe1Q020988 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Feb 2024 10:12:40 GMT Received: from [10.218.35.239] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 28 Feb 2024 02:12:37 -0800 Message-ID: Date: Wed, 28 Feb 2024 15:42:34 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] usb: xhci: Add error handling in xhci_map_urb_for_dma Content-Language: en-US To: Sergei Shtylyov , Greg Kroah-Hartman , Mathias Nyman CC: , , References: <20240228083343.3101303-1-quic_prashk@quicinc.com> From: Prashanth K In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 8Mnyt1hv2vzWnDYJ_Yp88sZJ_-e3o_Gc X-Proofpoint-ORIG-GUID: 8Mnyt1hv2vzWnDYJ_Yp88sZJ_-e3o_Gc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-28_04,2024-02-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=659 clxscore=1011 malwarescore=0 phishscore=0 adultscore=0 priorityscore=1501 spamscore=0 bulkscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402280080 On 28-02-24 02:31 pm, Sergei Shtylyov wrote: > On 2/28/24 11:33 AM, Prashanth K wrote: > >> 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 -EAGAIN if kzalloc returns null pointer. >> >> Cc: # 5.11 >> Fixes: 2017a1e58472 ("usb: xhci: Use temporary buffer to consolidate SG") >> Signed-off-by: Prashanth K >> --- >> drivers/usb/host/xhci.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c >> index c057c42c36f4..0597a60bec34 100644 >> --- a/drivers/usb/host/xhci.c >> +++ b/drivers/usb/host/xhci.c >> @@ -1218,6 +1218,9 @@ static int xhci_map_temp_buffer(struct usb_hcd *hcd, struct urb *urb) >> temp = kzalloc_node(buf_len, GFP_ATOMIC, >> dev_to_node(hcd->self.sysdev)); >> > > I don't think we need an empty line here. > >> + if (!temp) >> + return -EAGAIN; > > Not -ENOMEM? Yea that sounds better, will update in next patch. Thanks!