DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Singh, Aman Deep" <aman.deep.singh@intel.com>
To: Steve Yang <stevex.yang@intel.com>, <dev@dpdk.org>
Cc: <Yuying.Zhang@intel.com>, <qiming.yang@intel.com>,
	<qi.z.zhang@intel.com>,  Ferruh Yigit <ferruh.yigit@intel.com>
Subject: Re: [PATCH 2/2] app/testpmd: fix stack overflow for EEPROM display
Date: Wed, 2 Feb 2022 15:30:25 +0530	[thread overview]
Message-ID: <261cd7e4-a166-bf48-98e0-8bf6e257a7b4@intel.com> (raw)
In-Reply-To: <20220120025931.574106-3-stevex.yang@intel.com>

[-- Attachment #1: Type: text/plain, Size: 2388 bytes --]

Hi Steve
The patch looks ok to me.

On 1/20/2022 8:29 AM, Steve Yang wrote:
> When the size of EEPROM exceeds the default thread stack size(8MB),
> e.g.: 10Mb size, it will be cashed with stack overflow.
Just spelling: 10Mb/10MB, cashed/crashed
Can even rephrase, like: it will crash due to stack overflow
> Allocate the data of EPPROM information on the heap.
>
> Fixes: 6b67721dee2a ("app/testpmd: add EEPROM command")
>
> Signed-off-by: Steve Yang<stevex.yang@intel.com>

Acked-by: Aman Singh <aman.deep.singh@intel.com>

> ---
>   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

[-- Attachment #2: Type: text/html, Size: 3661 bytes --]

  reply	other threads:[~2022-02-02 10:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-20  2:59 [PATCH 0/2] add module EEPROM ops for ice Steve Yang
2022-01-20  2:59 ` [PATCH 1/2] net/ice: " Steve Yang
2022-01-25  1:15   ` Zhang, Qi Z
2022-01-25 14:49   ` Ferruh Yigit
2022-01-26  0:53     ` Yang, SteveX
2022-01-20  2:59 ` [PATCH 2/2] app/testpmd: fix stack overflow for EEPROM display Steve Yang
2022-02-02 10:00   ` Singh, Aman Deep [this message]
2022-02-03 13:15     ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=261cd7e4-a166-bf48-98e0-8bf6e257a7b4@intel.com \
    --to=aman.deep.singh@intel.com \
    --cc=Yuying.Zhang@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@intel.com \
    --cc=stevex.yang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).