From 47aaedeb94520fbb57971c89caa01d2e2ed191c5 Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Tue, 18 Jun 2024 00:17:15 +0700 Subject: [PATCH] fix(usb): fix warnings found by GNU static analyzer --- components/usb/usb_phy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/usb/usb_phy.c b/components/usb/usb_phy.c index a14d3a2146..fbd1aeee77 100644 --- a/components/usb/usb_phy.c +++ b/components/usb/usb_phy.c @@ -395,8 +395,10 @@ esp_err_t usb_new_phy(const usb_phy_config_t *config, usb_phy_handle_t *handle_r return ESP_OK; cleanup: - free(phy_context->iopins); - free(phy_context); + if (phy_context) { + free(phy_context->iopins); + free(phy_context); + } if (p_phy_ctrl_obj->ref_count == 0) { free(p_phy_ctrl_obj); p_phy_ctrl_obj = NULL;