From e7e76f6c0c41cf008d4b6ec8ca9ada440516d1de Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Thu, 13 Jun 2024 11:28:35 +0800 Subject: [PATCH] fix(touch): fix driver coverity issue --- .../hw_ver3/touch_version_specific.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c b/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c index bd990ba47d..acc88c09c5 100644 --- a/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c +++ b/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c @@ -326,10 +326,10 @@ esp_err_t touch_sensor_config_sleep_wakeup(touch_sensor_handle_t sens_handle, co xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); - ESP_GOTO_ON_FALSE(sleep_cfg->slp_wakeup_lvl == TOUCH_LIGHT_SLEEP_WAKEUP || sleep_cfg->slp_wakeup_lvl == TOUCH_DEEP_SLEEP_WAKEUP, - ESP_ERR_INVALID_ARG, err, TAG, "Invalid sleep level"); if (sleep_cfg) { + ESP_GOTO_ON_FALSE(sleep_cfg->slp_wakeup_lvl == TOUCH_LIGHT_SLEEP_WAKEUP || sleep_cfg->slp_wakeup_lvl == TOUCH_DEEP_SLEEP_WAKEUP, + ESP_ERR_INVALID_ARG, err, TAG, "Invalid sleep level"); /* Enabled touch sensor as wake-up source */ ESP_GOTO_ON_ERROR(esp_sleep_enable_touchpad_wakeup(), err, TAG, "Failed to enable touch sensor wakeup"); #if SOC_PM_SUPPORT_RC_FAST_PD @@ -408,7 +408,9 @@ esp_err_t touch_sensor_config_waterproof(touch_sensor_handle_t sens_handle, cons touch_ll_waterproof_enable(false); touch_ll_waterproof_set_guard_chan(TOUCH_LL_NULL_CHANNEL); touch_ll_waterproof_set_shield_chan_mask(0); - touch_ll_enable_scan_mask(BIT(wp_cfg->shield_chan->id), true); + if (sens_handle->shield_chan) { + touch_ll_enable_scan_mask(BIT(sens_handle->shield_chan->id), true); + } touch_ll_waterproof_set_shield_driver(0); sens_handle->guard_chan = NULL; sens_handle->shield_chan = NULL;