From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web12.3398.1602726604225638273 for ; Wed, 14 Oct 2020 18:50:04 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: heng.luo@intel.com) IronPort-SDR: dS8kgdwRi72jZA0Hhxpp7HoNHkqsID6iYfbmaDPtHrvCdcsKiwbLktGgaPSZu9FR+taxVOdr0e RQ8sLHD0b2cw== X-IronPort-AV: E=McAfee;i="6000,8403,9774"; a="154063496" X-IronPort-AV: E=Sophos;i="5.77,376,1596524400"; d="scan'208";a="154063496" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2020 18:50:03 -0700 IronPort-SDR: SDfGPiY+8B7evixUOQ2aNpBV9oCSWg0MwNPyTSrITOmnThEIp4bTO6NZah8udOXJqM/Q7kk/XJ BvF8zkRRgaYA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,376,1596524400"; d="scan'208";a="531065319" Received: from hengluo-dev.ccr.corp.intel.com ([10.239.153.154]) by orsmga005.jf.intel.com with ESMTP; 14 Oct 2020 18:50:02 -0700 From: "Heng Luo" To: devel@edk2.groups.io Cc: Ray Ni , Hao A Wu Subject: [PATCH] XhciDxe: Clean up UsbDevContext if USB slot initialization is failed Date: Thu, 15 Oct 2020 09:49:00 +0800 Message-Id: <20201015014901.1154-1-heng.luo@intel.com> X-Mailer: git-send-email 2.24.0.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3007 Currently UsbDevContext is not cleaned up if USB slot initialization is failed, the wrong context data will affect next USB devices and the USB devices can not be enumerated. Need to clean up UsbDevContext if USB slot initialization is failed. Cc: Ray Ni Cc: Hao A Wu Signed-off-by: Heng Luo --- MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pc= i/XhciDxe/XhciSched.c index 9cb115363c..1e8430ac34 100644 --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c @@ -2,7 +2,7 @@ =0D XHCI transfer scheduling routines.=0D =0D -Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2011 - 2020, Intel Corporation. All rights reserved.
=0D Copyright (c) Microsoft Corporation.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -2279,6 +2279,9 @@ XhcInitializeDeviceSlot ( DeviceAddress =3D (UINT8) ((DEVICE_CONTEXT *) OutputContext)->Slot.Dev= iceAddress;=0D DEBUG ((EFI_D_INFO, " Address %d assigned successfully\n", DeviceAd= dress));=0D Xhc->UsbDevContext[SlotId].XhciDevAddr =3D DeviceAddress;=0D + } else {=0D + DEBUG ((DEBUG_INFO, " Address %d assigned unsuccessfully, clean up = context data.\n"));=0D + ZeroMem (&Xhc->UsbDevContext[SlotId], sizeof (USB_DEV_CONTEXT));=0D }=0D =0D return Status;=0D @@ -2489,7 +2492,11 @@ XhcInitializeDeviceSlot64 ( DeviceAddress =3D (UINT8) ((DEVICE_CONTEXT_64 *) OutputContext)->Slot.= DeviceAddress;=0D DEBUG ((EFI_D_INFO, " Address %d assigned successfully\n", DeviceAd= dress));=0D Xhc->UsbDevContext[SlotId].XhciDevAddr =3D DeviceAddress;=0D + } else {=0D + DEBUG ((DEBUG_INFO, " Address %d assigned unsuccessfully, clean up = context data.\n"));=0D + ZeroMem (&Xhc->UsbDevContext[SlotId], sizeof (USB_DEV_CONTEXT));=0D }=0D +=0D return Status;=0D }=0D =0D --=20 2.24.0.windows.2