LF-1876 imx8: snvs_security: Fix dead code in apply_snvs_dgo_config
authorYe Li <ye.li@nxp.com>
Mon, 3 Aug 2020 10:06:22 +0000 (03:06 -0700)
committerYe Li <ye.li@nxp.com>
Thu, 29 Apr 2021 10:26:13 +0000 (03:26 -0700)
Fix Coverity Issue 10045175. In apply_snvs_dgo_config, code can never
be reached because of a logical contradiction. So assign the sciErr
to dgo_write return.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
(cherry picked from commit e395035a52962a84e132b6767871c1b8205ea026)
(cherry picked from commit 8b3337632ea9143338be6b37d1f90e6316fa05a6)

arch/arm/mach-imx/imx8/snvs_security_sc.c

index 8ae58eb..f3c094f 100644 (file)
@@ -229,9 +229,9 @@ exit:
        return (scierr == SC_ERR_NONE) ? 0 : -EIO;
 }
 
-static sc_err_t dgo_write(u32 _id, u8 _access, u32 *_pdata)
+static int dgo_write(u32 _id, u8 _access, u32 *_pdata)
 {
-       sc_err_t scierr = sc_seco_secvio_dgo_config(-1, _id, _access, _pdata);
+       int scierr = sc_seco_secvio_dgo_config(-1, _id, _access, _pdata);
 
        if (scierr != SC_ERR_NONE) {
                printf("Failed to set dgo configuration\n");
@@ -243,7 +243,7 @@ static sc_err_t dgo_write(u32 _id, u8 _access, u32 *_pdata)
 
 static int apply_snvs_dgo_config(struct snvs_dgo_conf *cnf)
 {
-       sc_err_t scierr = 0;
+       int scierr = 0;
 
        debug("%s\n", __func__);
 
@@ -261,28 +261,28 @@ static int apply_snvs_dgo_config(struct snvs_dgo_conf *cnf)
                        cnf->tamper_misc_ctl,
                        cnf->tamper_core_volt_mon_ctl);
 
-       dgo_write(0x04, 1, &cnf->tamper_offset_ctl);
+       scierr = dgo_write(0x04, 1, &cnf->tamper_offset_ctl);
        if (scierr != SC_ERR_NONE)
                goto exit;
 
-       dgo_write(0x14, 1, &cnf->tamper_pull_ctl);
+       scierr = dgo_write(0x14, 1, &cnf->tamper_pull_ctl);
        if (scierr != SC_ERR_NONE)
                goto exit;
 
-       dgo_write(0x24, 1, &cnf->tamper_ana_test_ctl);
+       scierr = dgo_write(0x24, 1, &cnf->tamper_ana_test_ctl);
        if (scierr != SC_ERR_NONE)
                goto exit;
 
-       dgo_write(0x34, 1, &cnf->tamper_sensor_trim_ctl);
+       scierr = dgo_write(0x34, 1, &cnf->tamper_sensor_trim_ctl);
        if (scierr != SC_ERR_NONE)
                goto exit;
 
-       dgo_write(0x54, 1, &cnf->tamper_core_volt_mon_ctl);
+       scierr = dgo_write(0x54, 1, &cnf->tamper_core_volt_mon_ctl);
        if (scierr != SC_ERR_NONE)
                goto exit;
 
        /* Last as it could lock the writes */
-       dgo_write(0x44, 1, &cnf->tamper_misc_ctl);
+       scierr = dgo_write(0x44, 1, &cnf->tamper_misc_ctl);
        if (scierr != SC_ERR_NONE)
                goto exit;