Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/32022
Change subject: northbridge/amd/pi: Fix null pointer check ......................................................................
northbridge/amd/pi: Fix null pointer check
- The `dev` pointer was being dereferenced before the null check. This fixes Coverity CID 1241851 (REVERSE_INULL) - Apply clang-format whitespace cleanups
Signed-off-by: Jacob Garber jgarber1@ualberta.ca Change-Id: Ie578787c3c26a1f3acb4567c135486667e88a888 --- M src/northbridge/amd/pi/00730F01/dimmSpd.c 1 file changed, 9 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/22/32022/1
diff --git a/src/northbridge/amd/pi/00730F01/dimmSpd.c b/src/northbridge/amd/pi/00730F01/dimmSpd.c index 79e046e..bdfb074 100644 --- a/src/northbridge/amd/pi/00730F01/dimmSpd.c +++ b/src/northbridge/amd/pi/00730F01/dimmSpd.c @@ -24,13 +24,16 @@
#include <northbridge/amd/pi/dimmSpd.h>
-AGESA_STATUS AmdMemoryReadSPD (UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info) +AGESA_STATUS AmdMemoryReadSPD(UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info) { - int spdAddress; DEVTREE_CONST struct device *dev = pcidev_on_root(0x18, 2); + + if (dev == 0) + return AGESA_ERROR; + DEVTREE_CONST struct northbridge_amd_pi_00730F01_config *config = dev->chip_info;
- if ((dev == 0) || (config == 0)) + if (config == 0) return AGESA_ERROR;
if (info->SocketId >= ARRAY_SIZE(config->spdAddrLookup)) @@ -40,13 +43,13 @@ if (info->DimmId >= ARRAY_SIZE(config->spdAddrLookup[0][0])) return AGESA_ERROR;
- spdAddress = config->spdAddrLookup - [info->SocketId] [info->MemChannelId] [info->DimmId]; + int spdAddress = config->spdAddrLookup + [info->SocketId][info->MemChannelId][info->DimmId];
if (spdAddress == 0) return AGESA_ERROR;
- int err = hudson_readSpd(spdAddress, (void *) info->Buffer, 128); + int err = hudson_readSpd(spdAddress, (void *)info->Buffer, 128); if (err) return AGESA_ERROR; return AGESA_SUCCESS;