John Zhao has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/56124 )
Change subject: soc/intel/common: Avoid NULL pointer deference ......................................................................
soc/intel/common: Avoid NULL pointer deference
Coverity detects dereference pointers req and res that are NULL when calling the pmc_send_ipc_cmd function. This change prevents NULL pointers dereference.
Found-by: Coverity CID 1458068, 1458070, 1458971, 1458073, 1458075, 1458076 TEST=None
Signed-off-by: John Zhao john.zhao@intel.com Change-Id: Ib88fa5f44dd33ad1ad2e763d79438b5c5b78acb4 --- M src/soc/intel/common/block/crashlog/crashlog.c 1 file changed, 9 insertions(+), 9 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/24/56124/1
diff --git a/src/soc/intel/common/block/crashlog/crashlog.c b/src/soc/intel/common/block/crashlog/crashlog.c index 433545a..c3d0cfd 100644 --- a/src/soc/intel/common/block/crashlog/crashlog.c +++ b/src/soc/intel/common/block/crashlog/crashlog.c @@ -194,8 +194,8 @@ int cl_pmc_re_arm_after_reset(void) {
- const struct pmc_ipc_buffer *req = { 0 }; - struct pmc_ipc_buffer *res = NULL; + const struct pmc_ipc_buffer req = { 0 }; + struct pmc_ipc_buffer res; uint32_t cmd_reg; int r;
@@ -203,7 +203,7 @@ PMC_IPC_CMD_ID_CRASHLOG_RE_ARM_ON_RESET, PMC_IPC_CMD_SIZE_SHIFT);
- r = pmc_send_ipc_cmd(cmd_reg, req, res); + r = pmc_send_ipc_cmd(cmd_reg, &req, &res);
if (r < 0) { printk(BIOS_ERR, "pmc_send_ipc_cmd failed in %s\n", __func__); @@ -217,8 +217,8 @@ /* Sends PMC IPC to clear CrashLog from PMC SSRAM area */ int cl_pmc_clear(void) { - const struct pmc_ipc_buffer *req = { 0 }; - struct pmc_ipc_buffer *res = NULL; + const struct pmc_ipc_buffer req = { 0 }; + struct pmc_ipc_buffer res; uint32_t cmd_reg; int r;
@@ -226,7 +226,7 @@ PMC_IPC_CMD_ID_CRASHLOG_ERASE, PMC_IPC_CMD_SIZE_SHIFT);
- r = pmc_send_ipc_cmd(cmd_reg, req, res); + r = pmc_send_ipc_cmd(cmd_reg, &req, &res);
if (r < 0) { printk(BIOS_ERR, "pmc_send_ipc_cmd failed in %s\n", __func__); @@ -244,8 +244,8 @@
int cl_pmc_en_gen_on_all_reboot(void) { - const struct pmc_ipc_buffer *req = { 0 }; - struct pmc_ipc_buffer *res = NULL; + const struct pmc_ipc_buffer req = { 0 }; + struct pmc_ipc_buffer res; uint32_t cmd_reg; int r;
@@ -253,7 +253,7 @@ PMC_IPC_CMD_ID_CRASHLOG_ON_RESET, PMC_IPC_CMD_SIZE_SHIFT);
- r = pmc_send_ipc_cmd(cmd_reg, req, res); + r = pmc_send_ipc_cmd(cmd_reg, &req, &res);
if (r < 0) { printk(BIOS_ERR, "pmc_send_ipc_cmd failed in %s\n", __func__);