USB: keyspan: fix tty line-status reporting
[pandora-kernel.git] / net / core / net-sysfs.c
index c71c434..0329404 100644 (file)
@@ -665,11 +665,14 @@ static ssize_t store_rps_dev_flow_table_cnt(struct netdev_rx_queue *queue,
        if (count) {
                int i;
 
-               if (count > 1<<30) {
+               if (count > INT_MAX)
+                       return -EINVAL;
+               count = roundup_pow_of_two(count);
+               if (count > (ULONG_MAX - sizeof(struct rps_dev_flow_table))
+                               / sizeof(struct rps_dev_flow)) {
                        /* Enforce a limit to prevent overflow */
                        return -EINVAL;
                }
-               count = roundup_pow_of_two(count);
                table = vmalloc(RPS_DEV_FLOW_TABLE_SIZE(count));
                if (!table)
                        return -ENOMEM;
@@ -987,9 +990,9 @@ static ssize_t store_xps_map(struct netdev_queue *queue,
                        nonempty = 1;
        }
 
-       if (nonempty)
-               RCU_INIT_POINTER(dev->xps_maps, new_dev_maps);
-       else {
+       if (nonempty) {
+               rcu_assign_pointer(dev->xps_maps, new_dev_maps);
+       else {
                kfree(new_dev_maps);
                RCU_INIT_POINTER(dev->xps_maps, NULL);
        }