datapath: Avoid possibility of negative 'n_flows' in struct odp_flowvec.
authorBen Pfaff <blp@nicira.com>
Mon, 10 May 2010 20:53:26 +0000 (13:53 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 13 May 2010 22:29:46 +0000 (15:29 -0700)
do_flowvec_ioctl() was checking for too-big 'n_flows' but not negative
'n_flows'.  We could add that check too, but 'n_flows' should never be
negative so it's better to just use an unsigned type.

datapath/datapath.c
include/openvswitch/datapath-protocol.h

index 79a1f63..eec998c 100644 (file)
@@ -1143,7 +1143,8 @@ error:
 static int query_flows(struct datapath *dp, const struct odp_flowvec *flowvec)
 {
        struct tbl *table = rcu_dereference(dp->table);
-       int i;
+       u32 i;
+
        for (i = 0; i < flowvec->n_flows; i++) {
                struct __user odp_flow *ufp = &flowvec->flows[i];
                struct odp_flow uf;
@@ -1167,8 +1168,8 @@ static int query_flows(struct datapath *dp, const struct odp_flowvec *flowvec)
 
 struct list_flows_cbdata {
        struct odp_flow __user *uflows;
-       int n_flows;
-       int listed_flows;
+       u32 n_flows;
+       u32 listed_flows;
 };
 
 static int list_flow(struct tbl_node *node, void *cbdata_)
index 94723ef..1c2dba9 100644 (file)
@@ -242,7 +242,7 @@ struct odp_flow_put {
 
 struct odp_flowvec {
     struct odp_flow *flows;
-    int n_flows;
+    __u32 n_flows;
 };
 
 /* The VLAN id is 12 bits, so we can use the entire 16 bits to indicate