From 1b8a3646ec786c9ff183bc9d6da960c4d38ac055 Mon Sep 17 00:00:00 2001 From: Johannes Kauffmann Date: Tue, 23 Jan 2024 09:04:54 +0100 Subject: [PATCH 1/4] simple_ng: fix linked list leak Don't overwrite the original pointer returned by ec_find_adapters(), otherwise the linked list is leaked. Instead, use a temporary variable, and pass the original pointer to ec_free_adapters(). --- test/simple_ng/simple_ng.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/simple_ng/simple_ng.c b/test/simple_ng/simple_ng.c index 835d7bcd..8ecc6345 100644 --- a/test/simple_ng/simple_ng.c +++ b/test/simple_ng/simple_ng.c @@ -287,15 +287,17 @@ main(int argc, char *argv[]) if (argc != 2) { ec_adaptert * adapter = NULL; + ec_adaptert * node = NULL; printf("Usage: simple_ng IFNAME1\n" "IFNAME1 is the NIC interface name, e.g. 'eth0'\n"); printf("\nAvailable adapters:\n"); adapter = ec_find_adapters(); - while (adapter != NULL) + node = adapter; + while (node != NULL) { - printf(" - %s (%s)\n", adapter->name, adapter->desc); - adapter = adapter->next; + printf(" - %s (%s)\n", node->name, node->desc); + node = node->next; } ec_free_adapters(adapter); return 1; From 034875d28041a5e72c0a56e780fc6a7e2fdcb2ef Mon Sep 17 00:00:00 2001 From: Johannes Kauffmann Date: Tue, 23 Jan 2024 09:18:59 +0100 Subject: [PATCH 2/4] simple_test: fix linked list leak Don't overwrite the original pointer returned by ec_find_adapters(), otherwise the linked list is leaked. Instead, use a temporary variable, and pass the original pointer to ec_free_adapters(). --- test/linux/simple_test/simple_test.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/linux/simple_test/simple_test.c b/test/linux/simple_test/simple_test.c index 8b9f70d1..8202127b 100644 --- a/test/linux/simple_test/simple_test.c +++ b/test/linux/simple_test/simple_test.c @@ -242,14 +242,16 @@ int main(int argc, char *argv[]) else { ec_adaptert * adapter = NULL; + ec_adaptert * node = NULL; printf("Usage: simple_test ifname1\nifname = eth0 for example\n"); printf ("\nAvailable adapters:\n"); adapter = ec_find_adapters (); - while (adapter != NULL) + node = adapter; + while (node != NULL) { - printf (" - %s (%s)\n", adapter->name, adapter->desc); - adapter = adapter->next; + printf (" - %s (%s)\n", node->name, node->desc); + node = node->next; } ec_free_adapters(adapter); } From f482687c2b914178c560f4f64242ecc5e79421f1 Mon Sep 17 00:00:00 2001 From: Johannes Kauffmann Date: Tue, 23 Jan 2024 09:21:08 +0100 Subject: [PATCH 3/4] eepromtool: fix linked list leak Don't overwrite the original pointer returned by ec_find_adapters(), otherwise the linked list is leaked. Instead, use a temporary variable, and pass the original pointer to ec_free_adapters(). --- test/linux/eepromtool/eepromtool.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/linux/eepromtool/eepromtool.c b/test/linux/eepromtool/eepromtool.c index 63b3213b..46aced56 100644 --- a/test/linux/eepromtool/eepromtool.c +++ b/test/linux/eepromtool/eepromtool.c @@ -457,6 +457,7 @@ int main(int argc, char *argv[]) else { ec_adaptert * adapter = NULL; + ec_adaptert * node = NULL; printf("Usage: eepromtool ifname slave OPTION fname|alias\n"); printf("ifname = eth0 for example\n"); @@ -470,10 +471,11 @@ int main(int argc, char *argv[]) printf ("\nAvailable adapters:\n"); adapter = ec_find_adapters (); - while (adapter != NULL) + node = adapter; + while (node != NULL) { - printf (" - %s (%s)\n", adapter->name, adapter->desc); - adapter = adapter->next; + printf (" - %s (%s)\n", node->name, node->desc); + node = node->next; } ec_free_adapters(adapter); } From 955655d81b21e3941eae61711b287a247b8115a0 Mon Sep 17 00:00:00 2001 From: Johannes Kauffmann Date: Tue, 23 Jan 2024 09:22:49 +0100 Subject: [PATCH 4/4] slaveinfo: fix linked list leak Don't overwrite the original pointer returned by ec_find_adapters(), otherwise the linked list is leaked. Instead, use a temporary variable, and pass the original pointer to ec_free_adapters(). --- test/linux/slaveinfo/slaveinfo.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/linux/slaveinfo/slaveinfo.c b/test/linux/slaveinfo/slaveinfo.c index 88558b18..5161d732 100644 --- a/test/linux/slaveinfo/slaveinfo.c +++ b/test/linux/slaveinfo/slaveinfo.c @@ -711,14 +711,16 @@ int main(int argc, char *argv[]) } else { + ec_adaptert * node; printf("Usage: slaveinfo ifname [options]\nifname = eth0 for example\nOptions :\n -sdo : print SDO info\n -map : print mapping\n"); printf ("Available adapters\n"); adapter = ec_find_adapters (); - while (adapter != NULL) + node = adapter; + while (node != NULL) { - printf ("Description : %s, Device to use for wpcap: %s\n", adapter->desc,adapter->name); - adapter = adapter->next; + printf ("Description : %s, Device to use for wpcap: %s\n", node->desc,node->name); + node = node->next; } ec_free_adapters(adapter); }