[dpdk-dev] l3fwd-acl: fix possible memory leak.

Message ID 1418749508-17748-1-git-send-email-konstantin.ananyev@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Ananyev, Konstantin Dec. 16, 2014, 5:05 p.m. UTC
  At error app_acl_init() can return without freeing dynamically allocated memory.
Not really a big problem, as if app_acl_init() fails,
then application would terminate immediately anyway.
Though it is a good coding practise to make a function to cleanup after itself.

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 examples/l3fwd-acl/main.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Thomas Monjalon Dec. 17, 2014, 12:12 a.m. UTC | #1
> At error app_acl_init() can return without freeing dynamically allocated memory.
> Not really a big problem, as if app_acl_init() fails,
> then application would terminate immediately anyway.
> Though it is a good coding practise to make a function to cleanup after itself.
> 
> Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

Applied

Thanks
  

Patch

diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index 4487c95..022ccab 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -1247,6 +1247,10 @@  app_acl_init(void)
 				acl_log("Socket %d of lcore %u is out "
 					"of range %d\n",
 					socketid, lcore_id, NB_SOCKETS);
+				free(route_base_ipv4);
+				free(route_base_ipv6);
+				free(acl_base_ipv4);
+				free(acl_base_ipv6);
 				return -1;
 			}