Klocwork: Fix the Null pointer derefernce found by klocwork
Signed-off-by: Thejaswani Putta <thejaswani.putta@intel.com> Change-Id: I15973ac28e9645826986cf63d2160eedb83024e4 Reviewed-on: https://review.coreboot.org/c/coreboot/+/32290 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Lijian Zhao <lijian.zhao@intel.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
21f9b3ecd7
commit
6f5225c7e0
|
@ -6,7 +6,8 @@ char *strdup(const char *s)
|
||||||
{
|
{
|
||||||
size_t sz = strlen(s) + 1;
|
size_t sz = strlen(s) + 1;
|
||||||
char *d = malloc(sz);
|
char *d = malloc(sz);
|
||||||
memcpy(d, s, sz);
|
if (d)
|
||||||
|
memcpy(d, s, sz);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +16,9 @@ char *strconcat(const char *s1, const char *s2)
|
||||||
size_t sz_1 = strlen(s1);
|
size_t sz_1 = strlen(s1);
|
||||||
size_t sz_2 = strlen(s2);
|
size_t sz_2 = strlen(s2);
|
||||||
char *d = malloc(sz_1 + sz_2 + 1);
|
char *d = malloc(sz_1 + sz_2 + 1);
|
||||||
memcpy(d, s1, sz_1);
|
if (d) {
|
||||||
memcpy(d + sz_1, s2, sz_2 + 1);
|
memcpy(d, s1, sz_1);
|
||||||
|
memcpy(d + sz_1, s2, sz_2 + 1);
|
||||||
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <soc/ramstage.h>
|
#include <soc/ramstage.h>
|
||||||
#include <soc/intel/broadwell/chip.h>
|
#include <soc/intel/broadwell/chip.h>
|
||||||
#include <soc/intel/common/acpi.h>
|
#include <soc/intel/common/acpi.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
/* Save wake source information for calculating ACPI _SWS values */
|
/* Save wake source information for calculating ACPI _SWS values */
|
||||||
int soc_fill_acpi_wake(uint32_t *pm1, uint32_t **gpe0)
|
int soc_fill_acpi_wake(uint32_t *pm1, uint32_t **gpe0)
|
||||||
|
@ -31,6 +32,8 @@ int soc_fill_acpi_wake(uint32_t *pm1, uint32_t **gpe0)
|
||||||
static uint32_t gpe0_sts[GPE0_REG_MAX];
|
static uint32_t gpe0_sts[GPE0_REG_MAX];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
assert(ps != NULL);
|
||||||
|
|
||||||
*pm1 = ps->pm1_sts & ps->pm1_en;
|
*pm1 = ps->pm1_sts & ps->pm1_en;
|
||||||
|
|
||||||
/* Mask off GPE0 status bits that are not enabled */
|
/* Mask off GPE0 status bits that are not enabled */
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cbfs_sections.h"
|
#include "cbfs_sections.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -65,6 +66,10 @@ bool fmd_process_flag_cbfs(const struct flashmap_descriptor *node)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
list_node = (struct descriptor_node *)malloc(sizeof(*list_node));
|
list_node = (struct descriptor_node *)malloc(sizeof(*list_node));
|
||||||
|
if (!list_node) {
|
||||||
|
ERROR("Cannot allocate CBFS flag node!\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
list_node->val = node;
|
list_node->val = node;
|
||||||
list_node->next = NULL;
|
list_node->next = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue