There is a memory leak when listing router rules in JSON format when a
rule doesn't match the requested address family.

Coverity report:
    CID 556928:         Resource leaks  (RESOURCE_LEAK)
    Variable "entry" going out of scope leaks the storage it points to.

Fixes: 5c30756a3739 ("ovs-router: Introduce ovs/route/rule/show command.")
Signed-off-by: Dima Chumak <[email protected]>
---
 lib/ovs-router.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/ovs-router.c b/lib/ovs-router.c
index 1ae4e64b2881..29800f1a4a20 100644
--- a/lib/ovs-router.c
+++ b/lib/ovs-router.c
@@ -855,11 +855,12 @@ ovs_router_rules_show_json(struct json *rule_entries, 
bool ipv6)
     struct ds ds;
 
     PVECTOR_FOR_EACH (rule, &rules) {
-        struct json *entry = json_object_create();
+        struct json *entry;
 
         if (rule->ipv4 == ipv6) {
             continue;
         }
+        entry = json_object_create();
 
         json_object_put(entry, "priority", json_integer_create(rule->prio));
         json_object_put(entry, "user", json_integer_create(rule->user));
-- 
2.52.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to