From b7365026284c8e13c0a9a912df660785fbd5aeb2 Mon Sep 17 00:00:00 2001 From: aleks Date: Wed, 19 Jan 2022 12:30:13 +0100 Subject: [PATCH] modbus: fix tcp slave destroy issues Closes https://github.com/espressif/esp-idf/issues/8211 --- .../freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.c | 4 ++-- components/freemodbus/tcp_slave/port/port_tcp_slave.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.c b/components/freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.c index 240a69ff6aa..64d9a90f792 100644 --- a/components/freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.c +++ b/components/freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -109,7 +109,7 @@ static esp_err_t mbc_tcp_slave_destroy(void) (void)vQueueDelete(mbs_opts->mbs_notification_queue_handle); (void)vEventGroupDelete(mbs_opts->mbs_event_group); (void)vMBTCPPortClose(); - + mbs_interface_ptr = NULL; vMBPortSetMode((UCHAR)MB_PORT_INACTIVE); return ESP_OK; } diff --git a/components/freemodbus/tcp_slave/port/port_tcp_slave.c b/components/freemodbus/tcp_slave/port/port_tcp_slave.c index fe1a27af141..de49308a18c 100644 --- a/components/freemodbus/tcp_slave/port/port_tcp_slave.c +++ b/components/freemodbus/tcp_slave/port/port_tcp_slave.c @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: BSD-3-Clause * - * SPDX-FileContributor: 2016-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2016-2022 Espressif Systems (Shanghai) CO LTD */ /* * FreeModbus Libary: ESP32 TCP Port @@ -668,6 +668,7 @@ vMBTCPPortDisable( void ) xConfig.pxMbClientInfo[i] = NULL; } } + free(xConfig.pxMbClientInfo); close(xListenSock); xListenSock = -1; vMBTCPPortRespQueueDelete(xConfig.xRespQueueHandle);