<p>Marc Jones has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/23211">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">soc/amd/common/pi: Fix issue in AGESA heap allocator<br><br>The heap allocator would try to split a buffer node that<br>was too small for another node. In the failing case, the buffer<br>node was 0x140 bytes and the requested size was 0x133 bytes.<br>The logic would check that there was room for the header and<br>buffer and try to split the buffer node. The buffer node header<br>is 0xC bytes, so 0x13F bytes need. The problem is that it didn't<br>leave room for another node header and a little space for a buffer.<br><br>BUG=b:71764350<br>TEST= Boot grunt.<br>BRANCH=none<br><br>Change-Id: Iece5e12d5787415a335bb953985331a5dc312152<br>Signed-off-by: Marc Jones <marcj303@gmail.com><br>---<br>M src/soc/amd/common/block/pi/heapmanager.c<br>1 file changed, 4 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/11/23211/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/soc/amd/common/block/pi/heapmanager.c b/src/soc/amd/common/block/pi/heapmanager.c</span><br><span>index cea3171..65a70e7 100644</span><br><span>--- a/src/soc/amd/common/block/pi/heapmanager.c</span><br><span>+++ b/src/soc/amd/common/block/pi/heapmanager.c</span><br><span>@@ -159,11 +159,12 @@</span><br><span>                                                     BestFitPrevNodeOffset);</span><br><span> </span><br><span>          /*</span><br><span style="color: hsl(0, 100%, 40%);">-               * If BestFitNode is larger than the requested buffer,</span><br><span style="color: hsl(0, 100%, 40%);">-           * fragment the node further</span><br><span style="color: hsl(120, 100%, 40%);">+           * If BestFitNode is larger than the requested buffer and</span><br><span style="color: hsl(120, 100%, 40%);">+              * has room another buffer node, fragment the node further</span><br><span>            */</span><br><span>          if (BestFitNodePtr->BufferSize ></span><br><span style="color: hsl(0, 100%, 40%);">-              (AllocParams->BufferLength + sizeof(BIOS_BUFFER_NODE))) {</span><br><span style="color: hsl(120, 100%, 40%);">+                  (AllocParams->BufferLength + sizeof(BIOS_BUFFER_NODE) +</span><br><span style="color: hsl(120, 100%, 40%);">+                     sizeof(BIOS_BUFFER_NODE) + sizeof(uint32_t))) {</span><br><span>                         NextFreeOffset = BestFitNodeOffset +</span><br><span>                                          AllocParams->BufferLength +</span><br><span>                                       sizeof(BIOS_BUFFER_NODE);</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/23211">change 23211</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/23211"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Iece5e12d5787415a335bb953985331a5dc312152 </div>
<div style="display:none"> Gerrit-Change-Number: 23211 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Marc Jones <marc@marcjonesconsulting.com> </div>