]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/8021q/vlanproc.c
[VLAN] net/8021q/vlanproc.c: fix check-after-use
[karo-tx-linux.git] / net / 8021q / vlanproc.c
index 5e24f72602a1b1a927938f8fe9b2e47cc6d32a98..bd08aa090763ad469e7e9c795f8057d8370e46f0 100644 (file)
@@ -69,7 +69,7 @@ static const char name_conf[]  = "config";
  *     Generic /proc/net/vlan/<file> file and inode operations
  */
 
-static struct seq_operations vlan_seq_ops = {
+static const struct seq_operations vlan_seq_ops = {
        .start = vlan_seq_start,
        .next = vlan_seq_next,
        .stop = vlan_seq_stop,
@@ -237,13 +237,9 @@ int vlan_proc_rem_dev(struct net_device *vlandev)
  * The following few functions build the content of /proc/net/vlan/config
  */
 
-/* starting at dev, find a VLAN device */
-static struct net_device *vlan_skip(struct net_device *dev)
+static inline int is_vlan_dev(struct net_device *dev)
 {
-       while (dev && !(dev->priv_flags & IFF_802_1Q_VLAN))
-               dev = dev->next;
-
-       return dev;
+       return dev->priv_flags & IFF_802_1Q_VLAN;
 }
 
 /* start read of /proc/net/vlan/config */
@@ -257,19 +253,35 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
        if (*pos == 0)
                return SEQ_START_TOKEN;
 
-       for (dev = vlan_skip(dev_base); dev && i < *pos;
-            dev = vlan_skip(dev->next), ++i);
+       for_each_netdev(dev) {
+               if (!is_vlan_dev(dev))
+                       continue;
+
+               if (i++ == *pos)
+                       return dev;
+       }
 
-       return  (i == *pos) ? dev : NULL;
+       return  NULL;
 }
 
 static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
+       struct net_device *dev;
+
        ++*pos;
 
-       return vlan_skip((v == SEQ_START_TOKEN)
-                           ? dev_base
-                           : ((struct net_device *)v)->next);
+       dev = (struct net_device *)v;
+       if (v == SEQ_START_TOKEN)
+               dev = net_device_entry(&dev_base_head);
+
+       for_each_netdev_continue(dev) {
+               if (!is_vlan_dev(dev))
+                       continue;
+
+               return dev;
+       }
+
+       return NULL;
 }
 
 static void vlan_seq_stop(struct seq_file *seq, void *v)
@@ -307,7 +319,7 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
        static const char fmt[] = "%30s %12lu\n";
        int i;
 
-       if ((vlandev == NULL) || (!(vlandev->priv_flags & IFF_802_1Q_VLAN)))
+       if (!(vlandev->priv_flags & IFF_802_1Q_VLAN))
                return 0;
 
        seq_printf(seq, "%s  VID: %d     REORDER_HDR: %i  dev->priv_flags: %hx\n",
@@ -330,7 +342,7 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
        seq_printf(seq, "Device: %s", dev_info->real_dev->name);
        /* now show all PRIORITY mappings relating to this VLAN */
        seq_printf(seq,
-                      "\nINGRESS priority mappings: 0:%lu  1:%lu  2:%lu  3:%lu  4:%lu  5:%lu  6:%lu 7:%lu\n",
+                      "\nINGRESS priority mappings: 0:%u  1:%u  2:%u  3:%u  4:%u  5:%u  6:%u 7:%u\n",
                       dev_info->ingress_priority_map[0],
                       dev_info->ingress_priority_map[1],
                       dev_info->ingress_priority_map[2],
@@ -345,7 +357,7 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
                const struct vlan_priority_tci_mapping *mp
                        = dev_info->egress_priority_map[i];
                while (mp) {
-                       seq_printf(seq, "%lu:%hu ",
+                       seq_printf(seq, "%u:%hu ",
                                   mp->priority, ((mp->vlan_qos >> 13) & 0x7));
                        mp = mp->next;
                }