Skip to content

Commit 7af3bdd

Browse files
committed
fix(drivers): some false reports from coverity
1 parent d46019b commit 7af3bdd

File tree

8 files changed

+14
-15
lines changed

8 files changed

+14
-15
lines changed

components/esp_driver_ana_cmpr/ana_cmpr_etm.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ static esp_err_t ana_cmpr_del_etm_event(esp_etm_event_handle_t base_event)
2323

2424
esp_err_t ana_cmpr_new_etm_event(ana_cmpr_handle_t cmpr, const ana_cmpr_etm_event_config_t *config, esp_etm_event_handle_t *ret_event)
2525
{
26-
esp_err_t ret = ESP_OK;
27-
ana_cmpr_etm_event_t *event = NULL;
2826
ana_cmpr_unit_t unit = ana_cmpr_get_unit_id(cmpr);
2927
ESP_RETURN_ON_FALSE(((int)unit) >= 0, ESP_ERR_INVALID_ARG, TAG, "invalid analog comparator handle");
3028
ESP_RETURN_ON_FALSE(config && ret_event, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
31-
event = heap_caps_calloc(1, sizeof(ana_cmpr_etm_event_t), ETM_MEM_ALLOC_CAPS);
32-
ESP_GOTO_ON_FALSE(event, ESP_ERR_NO_MEM, err, TAG, "no mem for analog comparator event");
29+
ana_cmpr_etm_event_t *event = heap_caps_calloc(1, sizeof(ana_cmpr_etm_event_t), ETM_MEM_ALLOC_CAPS);
30+
ESP_RETURN_ON_FALSE(event, ESP_ERR_NO_MEM, TAG, "no mem for analog comparator event");
3331

3432
uint32_t event_id = ANALOG_CMPR_LL_ETM_SOURCE(unit, config->event_type);
3533
event->base.del = ana_cmpr_del_etm_event;
@@ -38,11 +36,4 @@ esp_err_t ana_cmpr_new_etm_event(ana_cmpr_handle_t cmpr, const ana_cmpr_etm_even
3836
ESP_LOGD(TAG, "new event @%p, event_id=%"PRIu32", unit_id=%d", event, event_id, unit);
3937
*ret_event = &event->base;
4038
return ESP_OK;
41-
42-
err:
43-
if (event) {
44-
free(event);
45-
event = NULL;
46-
}
47-
return ret;
4839
}

components/esp_driver_parlio/src/parlio_rx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@ esp_err_t parlio_rx_unit_enable(parlio_rx_unit_handle_t rx_unit, bool reset_queu
740740
parlio_ll_rx_enable_clock(hal->regs, false);
741741
}
742742
}
743+
assert(trans.delimiter);
743744
parlio_rx_set_delimiter_config(rx_unit, trans.delimiter);
744745
parlio_rx_mount_transaction_buffer(rx_unit, &trans);
745746
gdma_start(rx_unit->dma_chan, (intptr_t)rx_unit->curr_desc);

components/esp_driver_ppa/src/ppa_blend.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ esp_err_t ppa_do_blend(ppa_client_handle_t ppa_client, const ppa_blend_oper_conf
258258

259259
esp_err_t ret = ESP_OK;
260260
ppa_trans_t *trans_elm = NULL;
261-
if (xQueueReceive(ppa_client->trans_elm_ptr_queue, (void *)&trans_elm, 0)) {
261+
if (xQueueReceive(ppa_client->trans_elm_ptr_queue, (void *)&trans_elm, 0) == pdTRUE) {
262+
assert(trans_elm);
262263
dma2d_trans_config_t *dma_trans_desc = trans_elm->trans_desc;
263264

264265
ppa_dma2d_trans_on_picked_config_t *trans_on_picked_desc = dma_trans_desc->user_config;

components/esp_driver_ppa/src/ppa_fill.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ esp_err_t ppa_do_fill(ppa_client_handle_t ppa_client, const ppa_fill_oper_config
113113

114114
esp_err_t ret = ESP_OK;
115115
ppa_trans_t *trans_elm = NULL;
116-
if (xQueueReceive(ppa_client->trans_elm_ptr_queue, (void *)&trans_elm, 0)) {
116+
if (xQueueReceive(ppa_client->trans_elm_ptr_queue, (void *)&trans_elm, 0) == pdTRUE) {
117+
assert(trans_elm);
117118
dma2d_trans_config_t *dma_trans_desc = trans_elm->trans_desc;
118119

119120
ppa_dma2d_trans_on_picked_config_t *trans_on_picked_desc = dma_trans_desc->user_config;

components/esp_driver_ppa/src/ppa_srm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ esp_err_t ppa_do_scale_rotate_mirror(ppa_client_handle_t ppa_client, const ppa_s
252252

253253
esp_err_t ret = ESP_OK;
254254
ppa_trans_t *trans_elm = NULL;
255-
if (xQueueReceive(ppa_client->trans_elm_ptr_queue, (void *)&trans_elm, 0)) {
255+
if (xQueueReceive(ppa_client->trans_elm_ptr_queue, (void *)&trans_elm, 0) == pdTRUE) {
256+
assert(trans_elm);
256257
dma2d_trans_config_t *dma_trans_desc = trans_elm->trans_desc;
257258

258259
ppa_dma2d_trans_on_picked_config_t *trans_on_picked_desc = dma_trans_desc->user_config;

components/esp_driver_touch_sens/common/touch_sens_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ touch_sensor_handle_t g_touch = NULL;
4242
static void touch_channel_pin_init(int id)
4343
{
4444
gpio_num_t pin = touch_sensor_channel_io_map[id];
45+
assert(pin >= 0);
4546
if (esp_gpio_reserve(BIT64(pin)) & BIT64(pin)) {
4647
ESP_LOGW(TAG, "The GPIO%d is conflict with other module", (int)pin);
4748
}

components/esp_driver_touch_sens/hw_ver1/touch_version_specific.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ esp_err_t touch_priv_config_controller(touch_sensor_handle_t sens_handle, const
198198
sens_handle->sample_cfg_num = 1; // Only have one set of sampling configuration
199199

200200
/* Configure the hardware */
201+
assert(hal_cfg.sample_cfg_num == 1);
201202
TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK);
202203
touch_hal_config_controller(&hal_cfg);
203204
touch_ll_reset_trigger_groups();

components/esp_driver_uart/src/uhci.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ static bool uhci_gdma_tx_callback_eof(gdma_channel_handle_t dma_chan, gdma_event
8888
expected_fsm = UHCI_TX_FSM_ENABLE;
8989
if (atomic_compare_exchange_strong(&uhci_ctrl->tx_dir.tx_fsm, &expected_fsm, UHCI_TX_FSM_RUN_WAIT)) {
9090
if (xQueueReceiveFromISR(uhci_ctrl->tx_dir.trans_queues[UHCI_TRANS_QUEUE_PROGRESS], &trans_desc, &do_yield) == pdTRUE) {
91+
// sanity check
92+
assert(trans_desc);
9193
atomic_store(&uhci_ctrl->tx_dir.tx_fsm, UHCI_TX_FSM_RUN);
9294
uhci_do_transmit(uhci_ctrl, trans_desc);
9395
if (do_yield) {
@@ -219,7 +221,7 @@ static esp_err_t uhci_gdma_initialize(uhci_controller_handle_t uhci_ctrl, const
219221
ESP_RETURN_ON_ERROR(gdma_new_link_list(&dma_link_config, &uhci_ctrl->rx_dir.dma_link), TAG, "DMA rx link list alloc failed");
220222
ESP_LOGD(TAG, "rx_dma node number is %d", uhci_ctrl->rx_dir.rx_num_dma_nodes);
221223

222-
uhci_ctrl->rx_dir.buffer_size_per_desc_node = heap_caps_calloc(uhci_ctrl->rx_dir.rx_num_dma_nodes, sizeof(uhci_ctrl->rx_dir.buffer_size_per_desc_node), UHCI_MEM_ALLOC_CAPS);
224+
uhci_ctrl->rx_dir.buffer_size_per_desc_node = heap_caps_calloc(uhci_ctrl->rx_dir.rx_num_dma_nodes, sizeof(*uhci_ctrl->rx_dir.buffer_size_per_desc_node), UHCI_MEM_ALLOC_CAPS);
223225
ESP_RETURN_ON_FALSE(uhci_ctrl->rx_dir.buffer_size_per_desc_node, ESP_ERR_NO_MEM, TAG, "no memory for recording buffer size for desc node");
224226
uhci_ctrl->rx_dir.buffer_pointers = heap_caps_calloc(uhci_ctrl->rx_dir.rx_num_dma_nodes, sizeof(*uhci_ctrl->rx_dir.buffer_pointers), UHCI_MEM_ALLOC_CAPS);
225227
ESP_RETURN_ON_FALSE(uhci_ctrl->rx_dir.buffer_pointers, ESP_ERR_NO_MEM, TAG, "no memory for recording buffer pointers for desc node");

0 commit comments

Comments
 (0)