Properly allocate flow action blocks in user-space switch.
authorJustin Pettit <jpettit@nicira.com>
Tue, 30 Sep 2008 21:19:47 +0000 (14:19 -0700)
committerJustin Pettit <jpettit@nicira.com>
Tue, 30 Sep 2008 21:19:47 +0000 (14:19 -0700)
The user-space switch was allocating blocks to hold actions in flows that
did not include the action header.

switch/switch-flow.c

index a42d00f..133e4f8 100644 (file)
@@ -173,11 +173,12 @@ struct sw_flow *
 flow_alloc(int n_actions)
 {
     struct sw_flow_actions *sfa;
+    size_t size = sizeof *sfa + (n_actions * sizeof sfa->actions[0]);
     struct sw_flow *flow = malloc(sizeof *flow);
     if (!flow)
         return NULL;
 
-    sfa = malloc(n_actions * sizeof sfa->actions[0]);
+    sfa = malloc(size);
     if (!sfa) {
         free(flow);
         return NULL;