<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace; background-color: rgb(255, 255, 255); display: inline !important">Reviewed-by: Andrei Warkentin <awarkentin@vmware.com></span><br>
</div>
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace; background-color: rgb(255, 255, 255); display: inline !important"><br>
</span></div>
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace; background-color: rgb(255, 255, 255); display: inline !important">Not using mLastMode is definitely an improvement, thanks. Esp. since mLastMode isn't a very good name for the variable (i.e. it's not the
 last mode set, it's the last possible/valid mode index, based on the virtual resolution modes enabled via Pcd/HII)</span></div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com><br>
<b>Sent:</b> Tuesday, July 21, 2020 9:01 PM<br>
<b>To:</b> devel@edk2.groups.io <devel@edk2.groups.io><br>
<b>Cc:</b> Leif Lindholm <leif@nuviainc.com>; Pete Batard <pete@akeo.ie>; Andrei Warkentin <awarkentin@vmware.com>; Ard Biesheuvel <ard.biesheuvel@arm.com><br>
<b>Subject:</b> [edk2-platform][PATCH v1 1/3] Platforms/RaspberryPi: Fix GOP parameter handling</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Handle incorrect parameters passed to DisplayDxe GOP functions<br>
QueryMode(), SetMode(), and Blt().<br>
<br>
This fixes Blt_Conf and QueryMode_Conf failures<br>
reported by SCT tests at:<br>
<a href="https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpftf%2FRPi4%2Fissues%2F73&amp;data=02%7C01%7Cawarkentin%40vmware.com%7C34c31d6924ca4f871d1b08d82de317b2%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C637309800678733611&amp;sdata=3BSdjglhhk%2FqRrP0mDOxV8YydE4vf0FdDkMnzabV5qY%3D&amp;reserved=0">https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpftf%2FRPi4%2Fissues%2F73&amp;data=02%7C01%7Cawarkentin%40vmware.com%7C34c31d6924ca4f871d1b08d82de317b2%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C637309800678733611&amp;sdata=3BSdjglhhk%2FqRrP0mDOxV8YydE4vf0FdDkMnzabV5qY%3D&amp;reserved=0</a><br>
<br>
Cc: Leif Lindholm <leif@nuviainc.com><br>
Cc: Pete Batard <pete@akeo.ie><br>
Cc: Andrei Warkentin <awarkentin@vmware.com><br>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com><br>
Signed-off-by: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@arm.com><br>
---<br>
 Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c | 15 ++++++++++++---<br>
 1 file changed, 12 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c<br>
index b880ca827bd6..80d0f7b2cb3c 100644<br>
--- a/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c<br>
+++ b/Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c<br>
@@ -1,5 +1,6 @@<br>
 /** @file<br>
  *<br>
+ *  Copyright (c) 2020, ARM Limited. All rights reserved.<br>
  *  Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin@gmail.com><br>
  *  Copyright (c) Microsoft Corporation. All rights reserved.<br>
  *<br>
@@ -170,7 +171,7 @@ DisplayQueryMode (<br>
   EFI_STATUS Status;<br>
   GOP_MODE_DATA *Mode;<br>
 <br>
-  if (ModeNumber > mLastMode) {<br>
+  if (Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) {<br>
     return EFI_INVALID_PARAMETER;<br>
   }<br>
 <br>
@@ -227,7 +228,7 @@ DisplaySetMode (<br>
   EFI_PHYSICAL_ADDRESS FbBase;<br>
   GOP_MODE_DATA *Mode = &mGopModeData[ModeNumber];<br>
 <br>
-  if (ModeNumber > mLastMode) {<br>
+ if (ModeNumber >= This->Mode->MaxMode) {<br>
     return EFI_UNSUPPORTED;<br>
   }<br>
 <br>
@@ -299,6 +300,14 @@ DisplayBlt (<br>
   UINT8 *VidBuf, *BltBuf, *VidBuf1;<br>
   UINTN i;<br>
 <br>
+  if ((UINTN)BltOperation >= EfiGraphicsOutputBltOperationMax) {<br>
+    return EFI_INVALID_PARAMETER;<br>
+  }<br>
+<br>
+  if (Width == 0 || Height == 0) {<br>
+    return EFI_INVALID_PARAMETER;<br>
+  }<br>
+<br>
   switch (BltOperation) {<br>
   case EfiBltVideoFill:<br>
     BltBuf = (UINT8*)BltBuffer;<br>
@@ -349,7 +358,7 @@ DisplayBlt (<br>
     break;<br>
 <br>
   default:<br>
-    ASSERT_EFI_ERROR (EFI_SUCCESS);<br>
+    return EFI_INVALID_PARAMETER;<br>
     break;<br>
   }<br>
 <br>
-- <br>
2.17.1<br>
<br>
</div>
</span></font></div>
</body>
</html>

<div width="1" style="color:white;clear:both">_._,_._,_</div>
<hr>
Groups.io Links:<p>


You receive all messages sent to this group.



<p>

<a target="_blank" href="https://edk2.groups.io/g/devel/message/63069">View/Reply Online (#63069)</a> |


  


|


  
    <a target="_blank" href="https://groups.io/mt/75717275/1813853">Mute This Topic</a>
  

| <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>



<br>

<a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> |
<a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |

<a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>

 [edk2-devel-archive@redhat.com]<br>
<div width="1" style="color:white;clear:both">_._,_._,_</div>