datapath: Check IS_ERR() in do_execute().
authorJesse Gross <jesse@nicira.com>
Wed, 15 Sep 2010 23:52:48 +0000 (16:52 -0700)
committerJustin Pettit <jpettit@nicira.com>
Tue, 5 Oct 2010 23:41:39 +0000 (16:41 -0700)
flow_actions_alloc() returns an error code in the form of a pointer
but we checked that the pointer was not NULL, which is always true.
This caused oopses on allocation errors when we would write into
an invalid pointer.

NIC-234

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath/datapath.c

index 5ee9157..fe37ec1 100644 (file)
@@ -1326,10 +1326,11 @@ static int do_execute(struct datapath *dp, const struct odp_execute *execute)
        if (execute->length < ETH_HLEN || execute->length > 65535)
                goto error;
 
-       err = -ENOMEM;
        actions = flow_actions_alloc(execute->n_actions);
-       if (!actions)
+       if (IS_ERR(actions)) {
+               err = PTR_ERR(actions);
                goto error;
+       }
 
        err = -EFAULT;
        if (copy_from_user(actions->actions, execute->actions,