From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 77B3FA00C3; Thu, 20 Jan 2022 04:06:17 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4A12841C28; Thu, 20 Jan 2022 04:06:11 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 0955941238 for ; Thu, 20 Jan 2022 04:06:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642647970; x=1674183970; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9HVSITo1RgLPNkvZaiyZZKtYPJmWZpAL5Fo2geAtj+8=; b=Q8ceKoHHy4zKEYz8cDmnyTW2kzwsj/sBUhosDBfuQ8cc5gtIUkGYXkvk x+4smvc0bePr9k5VR4FmzmSH4vO5sl5JTj3B0MpxdHgoErktQUG1nJ7op Js+IC0UZ90N2D4ltvHUWynx4gAn6oDpFVtbQcxZUFSyV2T9KodR3u1e7u wInG5LxBZJSV6lHf1BZ0ebLboR67ijvILaSGEayShKBOpNTUol7f1A7Px Y/xrZeAgVTa1yGG7zCzaQ3kOq/obug1SaPsmyFBbztBofJhXo6w7wIbN2 BKyIbqJvAhhx+6OyLEUl44cPdOj0BhSYkRcy4aKEKeX83sw4VVZGxaKOL Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10232"; a="331609506" X-IronPort-AV: E=Sophos;i="5.88,301,1635231600"; d="scan'208";a="331609506" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2022 19:06:09 -0800 X-IronPort-AV: E=Sophos;i="5.88,301,1635231600"; d="scan'208";a="518444170" Received: from intel-cd-odc-steve.cd.intel.com ([10.240.178.135]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jan 2022 19:06:07 -0800 From: Steve Yang To: dev@dpdk.org Cc: Yuying.Zhang@intel.com, aman.deep.singh@intel.com, qiming.yang@intel.com, qi.z.zhang@intel.com, Steve Yang Subject: [PATCH 2/2] app/testpmd: fix stack overflow for EEPROM display Date: Thu, 20 Jan 2022 02:59:31 +0000 Message-Id: <20220120025931.574106-3-stevex.yang@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220120025931.574106-1-stevex.yang@intel.com> References: <20220120025931.574106-1-stevex.yang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org When the size of EEPROM exceeds the default thread stack size(8MB), e.g.: 10Mb size, it will be cashed with stack overflow. Allocate the data of EPPROM information on the heap. Fixes: 6b67721dee2a ("app/testpmd: add EEPROM command") Signed-off-by: Steve Yang --- app/test-pmd/config.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 1722d6c8f8..e812f57151 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -912,10 +912,15 @@ port_eeprom_display(portid_t port_id) return; } - char buf[len_eeprom]; einfo.offset = 0; einfo.length = len_eeprom; - einfo.data = buf; + einfo.data = calloc(1, len_eeprom); + if (!einfo.data) { + fprintf(stderr, + "Allocation of port %u eeprom data failed\n", + port_id); + return; + } ret = rte_eth_dev_get_eeprom(port_id, &einfo); if (ret != 0) { @@ -933,10 +938,12 @@ port_eeprom_display(portid_t port_id) fprintf(stderr, "Unable to get EEPROM: %d\n", ret); break; } + free(einfo.data); return; } rte_hexdump(stdout, "hexdump", einfo.data, einfo.length); printf("Finish -- Port: %d EEPROM length: %d bytes\n", port_id, len_eeprom); + free(einfo.data); } void @@ -972,10 +979,15 @@ port_module_eeprom_display(portid_t port_id) return; } - char buf[minfo.eeprom_len]; einfo.offset = 0; einfo.length = minfo.eeprom_len; - einfo.data = buf; + einfo.data = calloc(1, minfo.eeprom_len); + if (!einfo.data) { + fprintf(stderr, + "Allocation of port %u eeprom data failed\n", + port_id); + return; + } ret = rte_eth_dev_get_module_eeprom(port_id, &einfo); if (ret != 0) { @@ -994,11 +1006,13 @@ port_module_eeprom_display(portid_t port_id) ret); break; } + free(einfo.data); return; } rte_hexdump(stdout, "hexdump", einfo.data, einfo.length); printf("Finish -- Port: %d MODULE EEPROM length: %d bytes\n", port_id, einfo.length); + free(einfo.data); } int -- 2.27.0