Browse Source

Merge "coverity: Fix MISRA null pointer violations" into integration

pull/1938/head
Mark Dykes 5 years ago
committed by TrustedFirmware Code Review
parent
commit
513b6165ee
  1. 4
      bl1/aarch64/bl1_context_mgmt.c
  2. 8
      bl1/bl1_main.c
  3. 14
      bl2/bl2_image_load_v2.c
  4. 12
      common/desc_image_load.c
  5. 8
      drivers/console/multi_console.c
  6. 6
      lib/utils/mem_region.c
  7. 4
      plat/arm/common/arm_bl2_setup.c

4
bl1/aarch64/bl1_context_mgmt.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -69,7 +69,7 @@ void bl1_prepare_next_image(unsigned int image_id)
security_state = GET_SECURITY_STATE(next_bl_ep->h.attr);
/* Setup the Secure/Non-Secure context if not done already. */
if (!cm_get_context(security_state))
if (cm_get_context(security_state) == NULL)
cm_set_context(&bl1_cpu_context[security_state], security_state);
/* Prepare the SPSR for the next BL image. */

8
bl1/bl1_main.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -26,7 +26,7 @@
/* BL1 Service UUID */
DEFINE_SVC_UUID2(bl1_svc_uid,
0xd46739fd, 0xcb72, 0x9a4d, 0xb5, 0x75,
U(0xd46739fd), 0xcb72, 0x9a4d, 0xb5, 0x75,
0x67, 0x15, 0xd6, 0xf4, 0xbb, 0x4a);
static void bl1_load_bl2(void);
@ -172,7 +172,7 @@ static void bl1_load_bl2(void)
/* Get the image descriptor */
image_desc = bl1_plat_get_image_desc(BL2_IMAGE_ID);
assert(image_desc);
assert(image_desc != NULL);
/* Get the image info */
image_info = &image_desc->image_info;
@ -276,7 +276,7 @@ register_t bl1_smc_wrapper(uint32_t smc_fid,
{
register_t x1, x2, x3, x4;
assert(handle);
assert(handle != NULL);
get_smc_params_from_ctx(handle, x1, x2, x3, x4);
return bl1_smc_handler(smc_fid, x1, x2, x3, x4, cookie, handle, flags);

14
bl2/bl2_image_load_v2.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -35,13 +35,13 @@ struct entry_point_info *bl2_load_images(void)
* Get information about the images to load.
*/
bl2_load_info = plat_get_bl_image_load_info();
assert(bl2_load_info);
assert(bl2_load_info->head);
assert(bl2_load_info != NULL);
assert(bl2_load_info->head != NULL);
assert(bl2_load_info->h.type == PARAM_BL_LOAD_INFO);
assert(bl2_load_info->h.version >= VERSION_2);
bl2_node_info = bl2_load_info->head;
while (bl2_node_info) {
while (bl2_node_info != NULL) {
/*
* Perform platform setup before loading the image,
* if indicated in the image attributes AND if NOT
@ -91,11 +91,11 @@ struct entry_point_info *bl2_load_images(void)
* Get information to pass to the next image.
*/
bl2_to_next_bl_params = plat_get_next_bl_params();
assert(bl2_to_next_bl_params);
assert(bl2_to_next_bl_params->head);
assert(bl2_to_next_bl_params != NULL);
assert(bl2_to_next_bl_params->head != NULL);
assert(bl2_to_next_bl_params->h.type == PARAM_BL_PARAMS);
assert(bl2_to_next_bl_params->h.version >= VERSION_2);
assert(bl2_to_next_bl_params->head->ep_info);
assert(bl2_to_next_bl_params->head->ep_info != NULL);
/* Populate arg0 for the next BL image if not already provided */
if (bl2_to_next_bl_params->head->ep_info->args.arg0 == (u_register_t)0)

12
common/desc_image_load.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -301,9 +301,9 @@ void bl31_params_parse_helper(u_register_t param,
image_info_t *bl33_image_info;
} *v1 = (void *)(uintptr_t)param;
assert(v1->h.type == PARAM_BL31);
if (bl32_ep_info_out)
if (bl32_ep_info_out != NULL)
*bl32_ep_info_out = *v1->bl32_ep_info;
if (bl33_ep_info_out)
if (bl33_ep_info_out != NULL)
*bl33_ep_info_out = *v1->bl33_ep_info;
return;
}
@ -311,12 +311,12 @@ void bl31_params_parse_helper(u_register_t param,
assert(v2->h.version == PARAM_VERSION_2);
assert(v2->h.type == PARAM_BL_PARAMS);
for (node = v2->head; node; node = node->next_params_info) {
for (node = v2->head; node != NULL; node = node->next_params_info) {
if (node->image_id == BL32_IMAGE_ID)
if (bl32_ep_info_out)
if (bl32_ep_info_out != NULL)
*bl32_ep_info_out = *node->ep_info;
if (node->image_id == BL33_IMAGE_ID)
if (bl33_ep_info_out)
if (bl33_ep_info_out != NULL)
*bl33_ep_info_out = *node->ep_info;
}
}

8
drivers/console/multi_console.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -90,7 +90,7 @@ int console_putc(int c)
console_t *console;
for (console = console_list; console != NULL; console = console->next)
if ((console->flags & console_state) && console->putc) {
if ((console->flags & console_state) && (console->putc != NULL)) {
int ret = do_putc(c, console);
if ((err == ERROR_NO_VALID_CONSOLE) || (ret < err))
err = ret;
@ -107,7 +107,7 @@ int console_getc(void)
do { /* Keep polling while at least one console works correctly. */
for (console = console_list; console != NULL;
console = console->next)
if ((console->flags & console_state) && console->getc) {
if ((console->flags & console_state) && (console->getc != NULL)) {
int ret = console->getc(console);
if (ret >= 0)
return ret;
@ -125,7 +125,7 @@ int console_flush(void)
console_t *console;
for (console = console_list; console != NULL; console = console->next)
if ((console->flags & console_state) && console->flush) {
if ((console->flags & console_state) && (console->flush != NULL)) {
int ret = console->flush(console);
if ((err == ERROR_NO_VALID_CONSOLE) || (ret < err))
err = ret;

6
lib/utils/mem_region.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -32,7 +32,7 @@ void clear_mem_regions(mem_region_t *tbl, size_t nregions)
{
size_t i;
assert(tbl);
assert(tbl != NULL);
assert(nregions > 0);
for (i = 0; i < nregions; i++) {
@ -114,7 +114,7 @@ int mem_region_in_array_chk(mem_region_t *tbl, size_t nregions,
uintptr_t region_start, region_end, start, end;
size_t i;
assert(tbl);
assert(tbl != NULL);
assert(nbytes > 0);
assert(!check_uptr_overflow(addr, nbytes-1));

4
plat/arm/common/arm_bl2_setup.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -150,7 +150,7 @@ int arm_bl2_handle_post_image_load(unsigned int image_id)
bl_mem_params_node_t *pager_mem_params = NULL;
bl_mem_params_node_t *paged_mem_params = NULL;
#endif
assert(bl_mem_params);
assert(bl_mem_params != NULL);
switch (image_id) {
#ifdef __aarch64__

Loading…
Cancel
Save