The --show-module-eeprom option stopped at the first port whose
module EEPROM could not be read, so a port without a module, or
a driver without the operation, hid the modules of all the next
ports. Report the error and go on with the next port, with the
port number in the message since several ports can now fail.

The EEPROM was also read into a fixed size buffer with the length
reported by the driver, without checking it. Skip the port if the
length does not fit the buffer.

Fixes: 0084463ea004 ("app/procinfo: dump module EEPROM info")
Cc: [email protected]

Signed-off-by: Roman Khromenok <[email protected]>
---
 app/proc-info/main.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 9c22fb8f01..d918a0a3c8 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -1869,9 +1869,15 @@ show_module_eeprom_info(void)
 
                ret = rte_eth_dev_get_module_info(i, &module_info);
                if (ret != 0) {
-                       fprintf(stderr, "Module EEPROM information read error: 
%s\n",
-                               strerror(-ret));
-                       return;
+                       fprintf(stderr, "Port %u module EEPROM information read 
error: %s\n",
+                               i, strerror(-ret));
+                       continue;
+               }
+
+               if (module_info.eeprom_len > sizeof(bytes_eeprom)) {
+                       fprintf(stderr, "Port %u module EEPROM too long: %u 
bytes\n",
+                               i, module_info.eeprom_len);
+                       continue;
                }
 
                eeprom_info.offset = 0;
@@ -1880,9 +1886,9 @@ show_module_eeprom_info(void)
 
                ret = rte_eth_dev_get_module_eeprom(i, &eeprom_info);
                if (ret != 0) {
-                       fprintf(stderr, "Module EEPROM read error: %s\n",
-                               strerror(-ret));
-                       return;
+                       fprintf(stderr, "Port %u module EEPROM read error: 
%s\n",
+                               i, strerror(-ret));
+                       continue;
                }
 
                rte_hexdump(stdout, "hexdump", eeprom_info.data,
-- 
2.47.3

Reply via email to