diff mbox

[ovs-dev] ofp-parse: Fix memory leak on error path in parse_ofp_group_mod_file().

Message ID 20170526232518.16792-1-blp@ovn.org
State Accepted
Headers show

Commit Message

Ben Pfaff May 26, 2017, 11:25 p.m. UTC
Found by Coverity.

Reported-by: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762655&defectInstanceId=4305334&mergedDefectId=180394
Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 lib/ofp-parse.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Justin Pettit June 1, 2017, 11:14 p.m. UTC | #1
> On May 26, 2017, at 4:25 PM, Ben Pfaff <blp@ovn.org> wrote:
> 
> Found by Coverity.
> 
> Reported-by: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762655&defectInstanceId=4305334&mergedDefectId=180394
> Signed-off-by: Ben Pfaff <blp@ovn.org>

Acked-by: Justin Pettit <jpettit@ovn.org>

--Justin
Ben Pfaff June 1, 2017, 11:26 p.m. UTC | #2
On Thu, Jun 01, 2017 at 04:14:06PM -0700, Justin Pettit wrote:
> 
> > On May 26, 2017, at 4:25 PM, Ben Pfaff <blp@ovn.org> wrote:
> > 
> > Found by Coverity.
> > 
> > Reported-by: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14762655&defectInstanceId=4305334&mergedDefectId=180394
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> 
> Acked-by: Justin Pettit <jpettit@ovn.org>

Thanks, applied to master and backported to 2.7 and 2.6.
diff mbox

Patch

diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index c8cac5b4765c..3b12a90dbd53 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -1,5 +1,5 @@ 
 /*
- * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
+ * Copyright (c) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1861,7 +1861,9 @@  parse_ofp_group_mod_file(const char *file_name, int command,
                 fclose(stream);
             }
 
-            return xasprintf("%s:%d: %s", file_name, line_number, error);
+            char *ret = xasprintf("%s:%d: %s", file_name, line_number, error);
+            free(error);
+            return ret;
         }
         *usable_protocols &= usable;
         *n_gms += 1;