[4/7] pipeline: fix memory free issues

Message ID 20201006203755.90779-4-cristian.dumitrescu@intel.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [1/7] pipeline: fix memory leak issue |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Cristian Dumitrescu Oct. 6, 2020, 8:37 p.m. UTC
  Fixes: 3ca60ceed7 ("pipeline: add SWX pipeline specification file")
Coverity issues: 362796, 362804, 362819, 362836, 362858, 362865,
362869

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 lib/librte_pipeline/rte_swx_pipeline_spec.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
  

Patch

diff --git a/lib/librte_pipeline/rte_swx_pipeline_spec.c b/lib/librte_pipeline/rte_swx_pipeline_spec.c
index 06e1ab438..a4bc8226a 100644
--- a/lib/librte_pipeline/rte_swx_pipeline_spec.c
+++ b/lib/librte_pipeline/rte_swx_pipeline_spec.c
@@ -35,9 +35,17 @@  struct extobj_spec {
 static void
 extobj_spec_free(struct extobj_spec *s)
 {
+	if (!s)
+		return;
+
 	free(s->name);
+	s->name = NULL;
+
 	free(s->extern_type_name);
+	s->extern_type_name = NULL;
+
 	free(s->pragma);
+	s->pragma = NULL;
 }
 
 static int
@@ -246,8 +254,14 @@  struct header_spec {
 static void
 header_spec_free(struct header_spec *s)
 {
+	if (!s)
+		return;
+
 	free(s->name);
+	s->name = NULL;
+
 	free(s->struct_type_name);
+	s->struct_type_name = NULL;
 }
 
 static int
@@ -297,7 +311,11 @@  struct metadata_spec {
 static void
 metadata_spec_free(struct metadata_spec *s)
 {
+	if (!s)
+		return;
+
 	free(s->struct_type_name);
+	s->struct_type_name = NULL;
 }
 
 static int