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;
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32022 )
Change subject: northbridge/amd/pi: Fix null pointer check ......................................................................
Patch Set 1:
(2 comments)
https://review.coreboot.org/#/c/32022/1/src/northbridge/amd/pi/00730F01/dimm... File src/northbridge/amd/pi/00730F01/dimmSpd.c:
https://review.coreboot.org/#/c/32022/1/src/northbridge/amd/pi/00730F01/dimm... PS1, Line 27: AGESA_STATUS AmdMemoryReadSPD(UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info) line over 80 characters
https://review.coreboot.org/#/c/32022/1/src/northbridge/amd/pi/00730F01/dimm... PS1, Line 47: [info->SocketId][info->MemChannelId][info->DimmId]; line over 80 characters
HAOUAS Elyes has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32022 )
Change subject: northbridge/amd/pi: Fix null pointer check ......................................................................
Patch Set 1: Code-Review+1
HAOUAS Elyes has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32022 )
Change subject: northbridge/amd/pi: Fix null pointer check ......................................................................
Patch Set 1:
here also: src/mainboard/amd/bettong/BiosCallOuts.c ?
HAOUAS Elyes has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32022 )
Change subject: northbridge/amd/pi: Fix null pointer check ......................................................................
Patch Set 1:
here also: src/mainboard/amd/bettong/BiosCallOuts.c ?
and src/northbridge/amd/pi/*/dimmSpd.c
Jacob Garber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32022 )
Change subject: northbridge/amd/pi: Fix null pointer check ......................................................................
Patch Set 1:
Patch Set 1:
here also: src/mainboard/amd/bettong/BiosCallOuts.c ?
and src/northbridge/amd/pi/*/dimmSpd.c
Ah yes, thanks. It's interesting those weren't flagged by Coverity.
Hello Kyösti Mälkki, HAOUAS Elyes, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32022
to look at the new patch set (#2).
Change subject: northbridge/amd/pi, mb/amd/bettong: Fix null pointer checks ......................................................................
northbridge/amd/pi, mb/amd/bettong: Fix null pointer checks
The dev pointers were being dereferenced before the null check. This fixes Coverity CID 1241851 (REVERSE_INULL)
Signed-off-by: Jacob Garber jgarber1@ualberta.ca Change-Id: Ie578787c3c26a1f3acb4567c135486667e88a888 --- M src/mainboard/amd/bettong/BiosCallOuts.c M src/northbridge/amd/pi/00630F01/dimmSpd.c M src/northbridge/amd/pi/00660F01/dimmSpd.c M src/northbridge/amd/pi/00730F01/dimmSpd.c 4 files changed, 24 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/22/32022/2
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32022 )
Change subject: northbridge/amd/pi, mb/amd/bettong: Fix null pointer checks ......................................................................
Patch Set 3: Code-Review+1
HAOUAS Elyes has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32022 )
Change subject: northbridge/amd/pi, mb/amd/bettong: Fix null pointer checks ......................................................................
Patch Set 3: Code-Review+1
Jacob Garber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32022 )
Change subject: northbridge/amd/pi, mb/amd/bettong: Fix null pointer checks ......................................................................
Patch Set 3:
(2 comments)
https://review.coreboot.org/#/c/32022/1/src/northbridge/amd/pi/00730F01/dimm... File src/northbridge/amd/pi/00730F01/dimmSpd.c:
https://review.coreboot.org/#/c/32022/1/src/northbridge/amd/pi/00730F01/dimm... PS1, Line 27: AGESA_STATUS AmdMemoryReadSPD(UINT32 unused1, UINTN unused2, AGESA_READ_SPD_PARAMS *info)
line over 80 characters
Done
https://review.coreboot.org/#/c/32022/1/src/northbridge/amd/pi/00730F01/dimm... PS1, Line 47: [info->SocketId][info->MemChannelId][info->DimmId];
line over 80 characters
Done
Hello Kyösti Mälkki, HAOUAS Elyes, Paul Menzel, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32022
to look at the new patch set (#4).
Change subject: nb/amd/pi, mb/amd/bettong: Fix null pointer checks ......................................................................
nb/amd/pi, mb/amd/bettong: Fix null pointer checks
The dev pointers were being dereferenced before the null check. Move the checks so they are done earlier.
Found-by: Coverity Scan, CID 1241851 (REVERSE_INULL) Signed-off-by: Jacob Garber jgarber1@ualberta.ca Change-Id: Ie578787c3c26a1f3acb4567c135486667e88a888 --- M src/mainboard/amd/bettong/BiosCallOuts.c M src/northbridge/amd/pi/00630F01/dimmSpd.c M src/northbridge/amd/pi/00660F01/dimmSpd.c M src/northbridge/amd/pi/00730F01/dimmSpd.c 4 files changed, 24 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/22/32022/4
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32022 )
Change subject: nb/amd/pi, mb/amd/bettong: Fix null pointer checks ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/#/c/32022/4/src/mainboard/amd/bettong/BiosCallOu... File src/mainboard/amd/bettong/BiosCallOuts.c:
https://review.coreboot.org/#/c/32022/4/src/mainboard/amd/bettong/BiosCallOu... PS4, Line 125: if (dev == 0) Please test pointers for NULL instead of 0. Or just (!dev).
Hello Kyösti Mälkki, HAOUAS Elyes, Paul Menzel, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/32022
to look at the new patch set (#5).
Change subject: nb/amd/pi, mb/amd/bettong: Fix null pointer checks ......................................................................
nb/amd/pi, mb/amd/bettong: Fix null pointer checks
The dev pointers were being dereferenced before the null check. Move the checks so they are done earlier.
Found-by: Coverity Scan, CID 1241851 (REVERSE_INULL) Signed-off-by: Jacob Garber jgarber1@ualberta.ca Change-Id: Ie578787c3c26a1f3acb4567c135486667e88a888 --- M src/mainboard/amd/bettong/BiosCallOuts.c M src/northbridge/amd/pi/00630F01/dimmSpd.c M src/northbridge/amd/pi/00660F01/dimmSpd.c M src/northbridge/amd/pi/00730F01/dimmSpd.c 4 files changed, 24 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/22/32022/5
Jacob Garber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32022 )
Change subject: nb/amd/pi, mb/amd/bettong: Fix null pointer checks ......................................................................
Patch Set 5:
(1 comment)
Compare pointers against NULL instead of 0
https://review.coreboot.org/#/c/32022/4/src/mainboard/amd/bettong/BiosCallOu... File src/mainboard/amd/bettong/BiosCallOuts.c:
https://review.coreboot.org/#/c/32022/4/src/mainboard/amd/bettong/BiosCallOu... PS4, Line 125: if (dev == 0)
Please test pointers for NULL instead of 0. Or just (!dev).
Done
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32022 )
Change subject: nb/amd/pi, mb/amd/bettong: Fix null pointer checks ......................................................................
Patch Set 5: Code-Review+2
Patrick Georgi has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/32022 )
Change subject: nb/amd/pi, mb/amd/bettong: Fix null pointer checks ......................................................................
nb/amd/pi, mb/amd/bettong: Fix null pointer checks
The dev pointers were being dereferenced before the null check. Move the checks so they are done earlier.
Found-by: Coverity Scan, CID 1241851 (REVERSE_INULL) Signed-off-by: Jacob Garber jgarber1@ualberta.ca Change-Id: Ie578787c3c26a1f3acb4567c135486667e88a888 Reviewed-on: https://review.coreboot.org/c/coreboot/+/32022 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/mainboard/amd/bettong/BiosCallOuts.c M src/northbridge/amd/pi/00630F01/dimmSpd.c M src/northbridge/amd/pi/00660F01/dimmSpd.c M src/northbridge/amd/pi/00730F01/dimmSpd.c 4 files changed, 24 insertions(+), 5 deletions(-)
Approvals: build bot (Jenkins): Verified Kyösti Mälkki: Looks good to me, approved
diff --git a/src/mainboard/amd/bettong/BiosCallOuts.c b/src/mainboard/amd/bettong/BiosCallOuts.c index 040de9b..e4020b0 100644 --- a/src/mainboard/amd/bettong/BiosCallOuts.c +++ b/src/mainboard/amd/bettong/BiosCallOuts.c @@ -121,14 +121,20 @@ AGESA_READ_SPD_PARAMS *info = ConfigPtr;
DEVTREE_CONST struct device *dev = pcidev_on_root(0x18, 2); + + if (dev == NULL) + return AGESA_ERROR; + DEVTREE_CONST struct northbridge_amd_pi_00660F01_config *config = dev->chip_info; + + if (config == NULL) + return AGESA_ERROR; + UINT8 spdAddrLookup_rev_F [2][2][4]= { { {0xA0, 0xA2}, {0xA4, 0xAC}, }, /* socket 0 - Channel 0 & 1 - 8-bit SPD addresses */ { {0x00, 0x00}, {0x00, 0x00}, }, /* socket 1 - Channel 0 & 1 - 8-bit SPD addresses */ };
- if ((dev == 0) || (config == 0)) - return AGESA_ERROR; if (info->SocketId >= ARRAY_SIZE(config->spdAddrLookup)) return AGESA_ERROR; if (info->MemChannelId >= ARRAY_SIZE(config->spdAddrLookup[0])) diff --git a/src/northbridge/amd/pi/00630F01/dimmSpd.c b/src/northbridge/amd/pi/00630F01/dimmSpd.c index f958b01..845dad1 100644 --- a/src/northbridge/amd/pi/00630F01/dimmSpd.c +++ b/src/northbridge/amd/pi/00630F01/dimmSpd.c @@ -28,9 +28,13 @@ { int spdAddress; DEVTREE_CONST struct device *dev = pcidev_on_root(0x18, 2); + + if (dev == NULL) + return AGESA_ERROR; + DEVTREE_CONST struct northbridge_amd_pi_00630F01_config *config = dev->chip_info;
- if ((dev == 0) || (config == 0)) + if (config == NULL) return AGESA_ERROR;
if (info->SocketId >= ARRAY_SIZE(config->spdAddrLookup)) diff --git a/src/northbridge/amd/pi/00660F01/dimmSpd.c b/src/northbridge/amd/pi/00660F01/dimmSpd.c index 0de7654..349dacf 100644 --- a/src/northbridge/amd/pi/00660F01/dimmSpd.c +++ b/src/northbridge/amd/pi/00660F01/dimmSpd.c @@ -27,10 +27,15 @@ { int spdAddress; DEVTREE_CONST struct device *dev = pcidev_on_root(0x18, 2); + + if (dev == NULL) + return AGESA_ERROR; + DEVTREE_CONST struct northbridge_amd_pi_00660F01_config *config = dev->chip_info;
- if ((dev == 0) || (config == 0)) + if (config == NULL) return AGESA_ERROR; + if (info->SocketId >= ARRAY_SIZE(config->spdAddrLookup)) return AGESA_ERROR; if (info->MemChannelId >= ARRAY_SIZE(config->spdAddrLookup[0])) diff --git a/src/northbridge/amd/pi/00730F01/dimmSpd.c b/src/northbridge/amd/pi/00730F01/dimmSpd.c index 79e046e..bbcac90 100644 --- a/src/northbridge/amd/pi/00730F01/dimmSpd.c +++ b/src/northbridge/amd/pi/00730F01/dimmSpd.c @@ -28,9 +28,13 @@ { int spdAddress; DEVTREE_CONST struct device *dev = pcidev_on_root(0x18, 2); + + if (dev == NULL) + return AGESA_ERROR; + DEVTREE_CONST struct northbridge_amd_pi_00730F01_config *config = dev->chip_info;
- if ((dev == 0) || (config == 0)) + if (config == NULL) return AGESA_ERROR;
if (info->SocketId >= ARRAY_SIZE(config->spdAddrLookup))