[HALX86] Minor fixes in HaliFindBusAddressTranslation()

- Remove ContextValue variable. This variable erroneously truncated
  *Context value (that can contain a pointer value) to 32 bits.

- Gracefully fail instead of asserting.
This commit is contained in:
Hermès Bélusca-Maïto 2023-06-10 14:11:36 +02:00
parent 4f41000714
commit 113656563a
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -1333,18 +1333,19 @@ HaliFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress,
PHAL_BUS_HANDLER BusHandler; PHAL_BUS_HANDLER BusHandler;
PBUS_HANDLER Handler; PBUS_HANDLER Handler;
PLIST_ENTRY NextEntry; PLIST_ENTRY NextEntry;
ULONG ContextValue;
/* Make sure we have a context */ /* Make sure we have a context */
if (!Context) return FALSE; if (!Context)
ASSERT((*Context) || (NextBus == TRUE)); return FALSE;
/* Read the context */ /* If we have data in the context, then this shouldn't be a new lookup */
ContextValue = *Context; if ((*Context != 0) && (NextBus != FALSE))
return FALSE;
/* Find the bus handler */ /* Find the bus handler */
Handler = HalpContextToBusHandler(ContextValue); Handler = HalpContextToBusHandler(*Context);
if (!Handler) return FALSE; if (!Handler)
return FALSE;
/* Check if this is an ongoing lookup */ /* Check if this is an ongoing lookup */
if (NextBus) if (NextBus)
@ -1354,7 +1355,8 @@ HaliFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress,
NextEntry = &BusHandler->AllHandlers; NextEntry = &BusHandler->AllHandlers;
/* Get the next one if we were already with one */ /* Get the next one if we were already with one */
if (ContextValue) NextEntry = NextEntry->Flink; if (*Context)
NextEntry = NextEntry->Flink;
/* Start scanning */ /* Start scanning */
while (TRUE) while (TRUE)
@ -1373,7 +1375,10 @@ HaliFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress,
BusHandler->Handler.BusNumber, BusHandler->Handler.BusNumber,
BusAddress, BusAddress,
AddressSpace, AddressSpace,
TranslatedAddress)) break; TranslatedAddress))
{
break;
}
/* Try the next one */ /* Try the next one */
NextEntry = NextEntry->Flink; NextEntry = NextEntry->Flink;
@ -1389,7 +1394,10 @@ HaliFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress,
Handler->BusNumber, Handler->BusNumber,
BusAddress, BusAddress,
AddressSpace, AddressSpace,
TranslatedAddress)) return FALSE; TranslatedAddress))
{
return FALSE;
}
/* Remember for next time */ /* Remember for next time */
*Context = (ULONG_PTR)Handler; *Context = (ULONG_PTR)Handler;