Fix warnings in some code scan
authorTracy Yi <tracy-yi@ti.com>
Sat, 27 Oct 2018 10:40:10 +0000 (18:40 +0800)
committerTracy Yi <tracy-yi@ti.com>
Sat, 27 Oct 2018 10:40:10 +0000 (18:40 +0800)
Signed-off-by: Tracy Yi <tracy-yi@ti.com>
tas2557-core.c
tas2557-misc.c
tas2557-regmap.c

index 4b947094ed9e506e065c3a3fb04b130c1f5e05c1..5b2e9db8bc36545ab761a4c8c4235670d1b86e07 100755 (executable)
@@ -291,6 +291,8 @@ end:
 
 static void failsafe(struct tas2557_priv *pTAS2557)
 {
+       int ret;
+
        dev_err(pTAS2557->dev, "%s\n", __func__);
        pTAS2557->mnErrCode |= ERROR_FAILSAFE;
        if (hrtimer_active(&pTAS2557->mtimer))
@@ -305,12 +307,20 @@ static void failsafe(struct tas2557_priv *pTAS2557)
                return;
        }
        pTAS2557->enableIRQ(pTAS2557, false, false);
-       tas2557_dev_load_data(pTAS2557, p_tas2557_shutdown_data);
+       ret = tas2557_dev_load_data(pTAS2557, p_tas2557_shutdown_data);
+       if (ret < 0)
+               dev_dbg(pTAS2557->dev, "failed load shutdown\n");
+
        pTAS2557->mbPowerUp = false;
        pTAS2557->hw_reset(pTAS2557);
-       pTAS2557->write(pTAS2557, TAS2557_SW_RESET_REG, 0x01);
+       ret = pTAS2557->write(pTAS2557, TAS2557_SW_RESET_REG, 0x01);
+       if (ret < 0)
+               dev_dbg(pTAS2557->dev, "failed sw reset\n");
+
        udelay(1000);
-       pTAS2557->write(pTAS2557, TAS2557_SPK_CTRL_REG, 0x04);
+       ret = pTAS2557->write(pTAS2557, TAS2557_SPK_CTRL_REG, 0x04);
+       if (ret < 0)
+               dev_dbg(pTAS2557->dev, "failed in spk ctrl\n");
        if (pTAS2557->mpFirmware != NULL)
                tas2557_clear_firmware(pTAS2557->mpFirmware);
 }
@@ -773,6 +783,11 @@ static int fw_parse_data(struct tas2557_priv *pTAS2557, struct TFirmware *pFirmw
 
        pImageData->mpBlocks =
                kmalloc(sizeof(struct TBlock) * pImageData->mnBlocks, GFP_KERNEL);
+        if(pImageData->mpBlocks == NULL)
+        {
+                dev_dbg(pTAS2557->dev, "failed malloc blocks mem\n");
+                goto end;
+        }
 
        for (nBlock = 0; nBlock < pImageData->mnBlocks; nBlock++) {
                n = fw_parse_block_data(pTAS2557, pFirmware,
@@ -831,6 +846,12 @@ static int fw_parse_program_data(struct tas2557_priv *pTAS2557,
 
        pFirmware->mpPrograms =
                kmalloc(sizeof(struct TProgram) * pFirmware->mnPrograms, GFP_KERNEL);
+       if(pFirmware->mpPrograms == NULL)
+       {
+               dev_dbg(pTAS2557->dev, "failed malloc program mem\n");
+               goto end;
+       }
+
        for (nProgram = 0; nProgram < pFirmware->mnPrograms; nProgram++) {
                pProgram = &(pFirmware->mpPrograms[nProgram]);
                memcpy(pProgram->mpName, pData, 64);
@@ -872,6 +893,12 @@ static int fw_parse_configuration_data(struct tas2557_priv *pTAS2557,
        pFirmware->mpConfigurations =
                kmalloc(sizeof(struct TConfiguration) * pFirmware->mnConfigurations,
                GFP_KERNEL);
+        if(pFirmware->mpConfigurations == NULL)
+        {
+                dev_dbg(pTAS2557->dev, "failed malloc configuration mem\n");
+                goto end;
+        }
+
        for (nConfiguration = 0; nConfiguration < pFirmware->mnConfigurations;
                nConfiguration++) {
                pConfiguration = &(pFirmware->mpConfigurations[nConfiguration]);
@@ -932,6 +959,12 @@ int fw_parse_calibration_data(struct tas2557_priv *pTAS2557,
 
        pFirmware->mpCalibrations =
                kmalloc(sizeof(struct TCalibration) * pFirmware->mnCalibrations, GFP_KERNEL);
+       if(pFirmware->mpCalibrations == NULL)
+       {
+               dev_err(pTAS2557->dev, "failed to malloc calibration mem\n");
+               goto end;
+       }
+
        for (nCalibration = 0;
                nCalibration < pFirmware->mnCalibrations;
                nCalibration++) {
index 32777acd100fbd725937462eec6d499881951d22..da19d41d8e4d1974f3ed03366b05525ae5376a32 100755 (executable)
@@ -440,7 +440,9 @@ static ssize_t tas2557_file_write(struct file *file, const char *buf, size_t cou
                        if (g_logEnable)
                                dev_info(pTAS2557->dev, "TIAUDIO_CMD_DACVOLUME, set to %d\n", volume);
 
-                       tas2557_set_DAC_gain(pTAS2557, volume);
+                       ret = tas2557_set_DAC_gain(pTAS2557, volume);
+                       if (ret < 0)
+                               goto err;
                }
        break;
 
index e9befd485964fb0b47855756b5d42166b4194595..da2f2d3337062659477a280a07a8dadec4e30c81 100755 (executable)
@@ -548,7 +548,8 @@ static enum hrtimer_restart temperature_timer_func(struct hrtimer *timer)
 static void timer_work_routine(struct work_struct *work)
 {
        struct tas2557_priv *pTAS2557 = container_of(work, struct tas2557_priv, mtimerwork);
-       int nResult, nTemp, nActTemp;
+       int nResult, nActTemp;
+       int nTemp = 0;
        struct TProgram *pProgram;
        static int nAvg;