Optional code to catch cases when loop cursor is used after for_each_netdev
loop: often it's a sign of a bug, since it isn't guaranteed to point to a
device.
Signed-off-by: Andrey Savochkin <[EMAIL PROTECTED]>
---
If anyone wants to keep this under some debug config option,
let me know which one.
netdevice.h | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletion(-)
--- ./include/linux/netdevice.h.vedevbase-dbg Mon Jul 3 16:16:51 2006
+++ ./include/linux/netdevice.h Mon Jul 3 16:16:51 2006
@@ -560,7 +560,13 @@ extern struct net_device loopback_dev;
extern struct list_head dev_base_head; /* All
devices */
extern rwlock_t dev_base_lock; /*
Device list lock */
-#define for_each_netdev(p) list_for_each_entry(p, &dev_base_head, dev_list)
+#define for_each_netdev(pos) \
+for (pos = list_entry(dev_base_head.next, typeof(*pos), dev_list); \
+ prefetch(pos->dev_list.next), \
+ &pos->dev_list != &dev_base_head ? : \
+ ({ void *__check_dev_use_after_for_each_netdev; \
+ pos = __check_dev_use_after_for_each_netdev; 0; }); \
+ pos = list_entry(pos->dev_list.next, typeof(*pos), dev_list))
/*
* When possible, it is preferrable to use for_each_netdev() loop
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html