Use xzalloc instead of xmalloc for some key structure allocations in
ofproto-dpif (viz. ofproto_dpif, ofport_dpif and rule_dpif) so as to
prevent uninitialized values in these structures.

Signed-off-by: Sabyasachi Sengupta <sabyasachi.sengu...@alcatel-lucent.com>

---
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index c1daa1d..c114027 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -812,7 +812,7 @@ static int add_internal_flows(struct ofproto_dpif *);
 static struct ofproto *
 alloc(void)
 {
-    struct ofproto_dpif *ofproto = xmalloc(sizeof *ofproto);
+    struct ofproto_dpif *ofproto = xzalloc(sizeof *ofproto);
     return &ofproto->up;
 }

@@ -1608,7 +1608,7 @@ query_tables(struct ofproto *ofproto,
 static struct ofport *
 port_alloc(void)
 {
-    struct ofport_dpif *port = xmalloc(sizeof *port);
+    struct ofport_dpif *port = xzalloc(sizeof *port);
     return &port->up;
 }

@@ -3876,7 +3876,7 @@ static struct rule_dpif *rule_dpif_cast(const struct rule *rule)
 static struct rule *
 rule_alloc(void)
 {
-    struct rule_dpif *rule = xmalloc(sizeof *rule);
+    struct rule_dpif *rule = xzalloc(sizeof *rule);
     return &rule->up;
 }

--

---
Nuage Networks Business Unit, Alcatel-Lucent,
755 Ravendale Drive, Mountain View, CA, 94043
Mailstop: 1127, Ph: 1-650-623-3461
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to