ofproto-dpif: Use xzalloc instead of xmalloc.
authorSabyasachi Sengupta <sabyasachi.sengupta@alcatel-lucent.com>
Sat, 6 Jun 2015 05:14:37 +0000 (22:14 -0700)
committerBen Pfaff <blp@nicira.com>
Sat, 6 Jun 2015 05:15:27 +0000 (22:15 -0700)
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.sengupta@alcatel-lucent.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto-dpif.c

index bd45305..22e5d5f 100644 (file)
@@ -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;
 }
 
@@ -3882,7 +3882,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;
 }