From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::244; helo=mail-wr0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 873932034EE25 for ; Sun, 5 Nov 2017 01:27:06 -0800 (PST) Received: by mail-wr0-x244.google.com with SMTP id 4so1713180wrt.0 for ; Sun, 05 Nov 2017 01:31:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=N4ro6MRLhZYpnci628/WuKKkJ98WOfOYxIkN8s0Wcto=; b=RDyRgsNRdvvoQ3CxxPRfAIH/oPJGWFsGU/OZN8mqrKYWW1XBGTVNKTGfJM8eklZ6Ma /WgdtZwFgevOGC3nhn5HKSwHSRzRaVYfbd5mpEzT2vtXSI/Yk8/og4rcyaD+Fl08m72B U/5I3/kxK3YEVVqCwj3B7Xiu+puei2J5m8OEk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=N4ro6MRLhZYpnci628/WuKKkJ98WOfOYxIkN8s0Wcto=; b=F1WhCXxn8FCeAK4/r+NEWnMdib4ffclBaO64w0TRzf1lLaPK2+Z7eIsmAFyf9cyH7R iwgfpnNDWoJcL3oswk0xCXiMYpKX8DZ8TQss5ORADcIFWNpXU6+tHW3kK4wDuCTkdfgR UJ6eACBqMqZmi0rs9ojZdYY8Fdrg2bTnd4UnG4DRx6zNdSfz0aqXJLRHmuk2y81PS8az CSGp2Bf96SnPrPfD2CxV9UFTH07Mal+RAcxRGpYtEqro9XwvKMNdaaJvkzX1ftmp0oMU hdg4OWWWAS3+4+F1E7gFl7bB6ZwCe9oCPtftN1uJab/B/FUmrwT9fqFUIJtUBlcQceyf AZiA== X-Gm-Message-State: AMCzsaX0t4L12ycRvH7zuJWgWBE7NCKych0LCtCk9ocY7FNtg1PWNF/q H98/I0BC2EzYqfa0pvoOWlFynb2EKDU= X-Google-Smtp-Source: ABhQp+TxHLvtxn9GAy5/N3M7MM56MFLFYCiozaUkFZFGlkNTgvhglxhCCz/+JmKmWDpgPTptzvvuRA== X-Received: by 10.223.130.196 with SMTP id 62mr10872497wrc.60.1509874261948; Sun, 05 Nov 2017 01:31:01 -0800 (PST) Received: from localhost.localdomain ([105.129.222.2]) by smtp.gmail.com with ESMTPSA id x65sm4304052wmg.11.2017.11.05.01.30.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Nov 2017 01:31:00 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Cc: feng.tian@intel.com, star.zeng@intel.com, eric.dong@intel.com, Ard Biesheuvel Date: Sun, 5 Nov 2017 09:30:54 +0000 Message-Id: <20171105093054.22349-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Subject: [PATCH v2] MdeModulePkg/SdMmcPciHcDxe: call SdMmcFreeTrb() to complete sync operation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Nov 2017 09:27:06 -0000 Currently, we complete a synchronous operation without unmapping the DMA mappings, and free the pages using FreePages () rather than calling EFI_PCI_IO_PROTOCOL::FreeBuffer. This is simply incorrecnt, but it also breaks non-coherent DMA as well as DMA protection and/or memory encryption so let's do it correctly and call SdMmcFreeTrb() instead. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c index 23faec5e2be0..0be8828abfcc 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c @@ -1008,13 +1008,7 @@ SdMmcPassThruPassThru ( } Done: - if ((Trb != NULL) && (Trb->AdmaDesc != NULL)) { - FreePages (Trb->AdmaDesc, Trb->AdmaPages); - } - - if (Trb != NULL) { - FreePool (Trb); - } + SdMmcFreeTrb (Trb); return Status; } -- 2.11.0