]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
fix(zynqmp): resolve coverity warnings
authorHariBabu Gattem <haribabu.gattem@amd.com>
Fri, 7 Oct 2022 07:07:49 +0000 (00:07 -0700)
committerBipin Ravi <bipin.ravi@arm.com>
Tue, 15 Nov 2022 23:17:46 +0000 (00:17 +0100)
Fix for coverity issues in pm_service component.
Fixed compilation error for versal platform.

Change-Id: I948f01807e67ad1e41021557e040dcbfb7b3a39e
Signed-off-by: HariBabu Gattem <haribabu.gattem@amd.com>
Signed-off-by: Naman Patel <naman.patel@amd.com>
plat/xilinx/common/include/pm_ipi.h
plat/xilinx/common/pm_service/pm_ipi.c
plat/xilinx/versal/pm_service/pm_svc_main.c
plat/xilinx/zynqmp/include/plat_ipi.h
plat/xilinx/zynqmp/pm_service/pm_client.c
plat/xilinx/zynqmp/pm_service/pm_svc_main.c

index 8a1566873c3958be9a21cd21434af985197292c6..52dfc4766ef70670354a6988ceb316f7f9987e8a 100644 (file)
@@ -16,7 +16,7 @@
 #define IPI_BLOCKING           1
 #define IPI_NON_BLOCKING       0
 
-int32_t pm_ipi_init(const struct pm_proc *proc);
+void pm_ipi_init(const struct pm_proc *proc);
 
 enum pm_ret_status pm_ipi_send(const struct pm_proc *proc,
                               uint32_t payload[PAYLOAD_ARG_CNT]);
index a0403cf113fad0a181365166a8e4f0b47e15d9ce..513d6be0a67eca350737ce36aa6e1cd62690a46d 100644 (file)
@@ -19,6 +19,7 @@
 #include "pm_ipi.h"
 
 #define ERROR_CODE_MASK                (0xFFFFU)
+#define PM_OFFSET              (0U)
 
 DEFINE_BAKERY_LOCK(pm_secure_lock);
 
@@ -33,12 +34,10 @@ DEFINE_BAKERY_LOCK(pm_secure_lock);
  *
  * Called from pm_setup initialization function
  */
-int32_t pm_ipi_init(const struct pm_proc *proc)
+void pm_ipi_init(const struct pm_proc *proc)
 {
        bakery_lock_init(&pm_secure_lock);
        ipi_mb_open(proc->ipi->local_ipi_id, proc->ipi->remote_ipi_id);
-
-       return 0;
 }
 
 /**
@@ -55,7 +54,7 @@ static enum pm_ret_status pm_ipi_send_common(const struct pm_proc *proc,
                                             uint32_t payload[PAYLOAD_ARG_CNT],
                                             uint32_t is_blocking)
 {
-       unsigned int offset = 0;
+       uint32_t offset = PM_OFFSET;
        uintptr_t buffer_base = proc->ipi->buffer_base +
                                        IPI_BUFFER_TARGET_REMOTE_OFFSET +
                                        IPI_BUFFER_REQ_OFFSET;
@@ -185,7 +184,7 @@ void pm_ipi_buff_read_callb(uint32_t *value, size_t count)
        size_t i;
 #if IPI_CRC_CHECK
        size_t j;
-       unsigned int response_payload[PAYLOAD_ARG_CNT];
+       unsigned int response_payload[PAYLOAD_ARG_CNT] = {0};
 #endif
        uintptr_t buffer_base = IPI_BUFFER_REMOTE_BASE +
                                IPI_BUFFER_TARGET_LOCAL_OFFSET +
index 48888e462d2ad1e54b05e8288984ad8ffa8ff61b..9eb426a374dac3d5ca2c82f299696f31f1d55e01 100644 (file)
@@ -119,16 +119,10 @@ int32_t pm_register_sgi(uint32_t sgi_num, uint32_t reset)
  */
 int32_t pm_setup(void)
 {
-       int32_t status, ret = 0;
+       int32_t ret = 0;
 
-       status = pm_ipi_init(primary_proc);
-
-       if (status < 0) {
-               INFO("BL31: PM Service Init Failed, Error Code %d!\n", status);
-               ret = status;
-       } else {
-               pm_up = true;
-       }
+       pm_ipi_init(primary_proc);
+       pm_up = true;
 
        /*
         * Enable IPI IRQ
index bccd2f1944868a4e2cfd2933a0eb573b6fd11d99..a78f93a189ed7226bd17cfd18eb0f7756318dca4 100644 (file)
@@ -41,7 +41,7 @@
 #define IPI_BUFFER_TARGET_LOCAL_OFFSET 0x80U
 #define IPI_BUFFER_TARGET_REMOTE_OFFSET        0x1C0U
 
-#define IPI_BUFFER_MAX_WORDS   8
+#define IPI_BUFFER_MAX_WORDS   8U
 
 #define IPI_BUFFER_REQ_OFFSET  0x0U
 #define IPI_BUFFER_RESP_OFFSET 0x20U
index a853e38788c4eefbac3dfb8dfb6cf8f1de9824f2..7217fa145975d658c10dd1e42f4b2c8699837559 100644 (file)
@@ -176,7 +176,7 @@ static enum pm_node_id irq_to_pm_node(uint32_t irq)
 static void pm_client_set_wakeup_sources(void)
 {
        uint32_t reg_num;
-       uint8_t pm_wakeup_nodes_set[NODE_MAX];
+       uint8_t pm_wakeup_nodes_set[NODE_MAX] = { 0 };
        uintptr_t isenabler1 = BASE_GICD_BASE + GICD_ISENABLER + 4U;
 
        /* In case of power-off suspend, only NODE_EXTERN must be set */
index b91878ea78d7d48adf90ace24697dab868aa5e72..03fa3163245d81678a3fd422801a99e43500d88c 100644 (file)
@@ -207,11 +207,10 @@ err:
  */
 int32_t pm_setup(void)
 {
-       int32_t status, ret;
 
-       status = pm_ipi_init(primary_proc);
+       pm_ipi_init(primary_proc);
 
-       ret = pm_get_api_version(&pm_ctx.api_version);
+       pm_get_api_version(&pm_ctx.api_version);
        if (pm_ctx.api_version < PM_VERSION) {
                ERROR("BL31: Platform Management API version error. Expected: "
                      "v%d.%d - Found: v%d.%d\n", PM_VERSION_MAJOR,
@@ -220,6 +219,7 @@ int32_t pm_setup(void)
                return -EINVAL;
        }
 
+       int32_t status = 0, ret = 0;
 #if ZYNQMP_WDT_RESTART
        status = pm_wdt_restart_setup();
        if (status)
@@ -263,7 +263,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
        uint32_t payload[PAYLOAD_ARG_CNT];
 
        uint32_t pm_arg[5];
-       uint32_t result[PAYLOAD_ARG_CNT];
+       uint32_t result[PAYLOAD_ARG_CNT] = {0};
        uint32_t api_id;
 
        /* Handle case where PM wasn't initialized properly */
@@ -350,7 +350,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
 
        case PM_FPGA_GET_STATUS:
        {
-               uint32_t value;
+               uint32_t value = 0;
 
                ret = pm_fpga_get_status(&value);
                SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
@@ -368,7 +368,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
                         (uint64_t)result[2] | ((uint64_t)result[3] << 32));
        case PM_IOCTL:
        {
-               uint32_t value;
+               uint32_t value = 0;
 
                ret = pm_ioctl(pm_arg[0], pm_arg[1], pm_arg[2],
                               pm_arg[3], &value);
@@ -395,7 +395,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
 
        case PM_CLOCK_GETSTATE:
        {
-               uint32_t value;
+               uint32_t value = 0;
 
                ret = pm_clock_getstate(pm_arg[0], &value);
                SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
@@ -407,7 +407,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
 
        case PM_CLOCK_GETDIVIDER:
        {
-               uint32_t value;
+               uint32_t value = 0;
 
                ret = pm_clock_getdivider(pm_arg[0], &value);
                SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
@@ -436,7 +436,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
 
        case PM_CLOCK_GETPARENT:
        {
-               uint32_t value;
+               uint32_t value = 0;
 
                ret = pm_clock_getparent(pm_arg[0], &value);
                SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32U);
@@ -470,7 +470,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
 
        case PM_FPGA_READ:
        {
-               uint32_t value;
+               uint32_t value = 0;
 
                ret = pm_fpga_read(pm_arg[0], pm_arg[1], pm_arg[2], pm_arg[3],
                                   &value);
@@ -479,7 +479,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
 
        case PM_SECURE_AES:
        {
-               uint32_t value;
+               uint32_t value = 0;
 
                ret = pm_aes_engine(pm_arg[0], pm_arg[1], &value);
                SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32U);
@@ -491,7 +491,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
 
        case PM_PLL_GET_PARAMETER:
        {
-               uint32_t value;
+               uint32_t value = 0;
 
                ret = pm_pll_get_parameter(pm_arg[0], pm_arg[1], &value);
                SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value << 32U));
@@ -503,7 +503,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
 
        case PM_PLL_GET_MODE:
        {
-               uint32_t mode;
+               uint32_t mode = 0;
 
                ret = pm_pll_get_mode(pm_arg[0], &mode);
                SMC_RET1(handle, (uint64_t)ret | ((uint64_t)mode << 32U));
@@ -511,7 +511,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
 
        case PM_REGISTER_ACCESS:
        {
-               uint32_t value;
+               uint32_t value = 0;
 
                ret = pm_register_access(pm_arg[0], pm_arg[1], pm_arg[2],
                                         pm_arg[3], &value);
@@ -520,7 +520,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
 
        case PM_EFUSE_ACCESS:
        {
-               uint32_t value;
+               uint32_t value = 0;
 
 #if defined(ZYNQMP_SECURE_EFUSES)
                if (is_caller_non_secure(flags)) {