Skip to content

Commit

Permalink
6LoWPAN: use the _safe version of list_for_each
Browse files Browse the repository at this point in the history
When we kfree(entry) that causes a use-after-free bug so we have to
use list_for_each_entry_safe() safe here.

Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
error27 authored and davem330 committed Sep 15, 2011
1 parent 90d0963 commit aec9db3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/ieee802154/6lowpan.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,15 +813,17 @@ static void lowpan_dellink(struct net_device *dev, struct list_head *head)
struct lowpan_dev_info *lowpan_dev = lowpan_dev_info(dev);
struct net_device *real_dev = lowpan_dev->real_dev;
struct lowpan_dev_record *entry;
struct lowpan_dev_record *tmp;

ASSERT_RTNL();

mutex_lock(&lowpan_dev_info(dev)->dev_list_mtx);
list_for_each_entry(entry, &lowpan_devices, list)
list_for_each_entry_safe(entry, tmp, &lowpan_devices, list) {
if (entry->ldev == dev) {
list_del(&entry->list);
kfree(entry);
}
}
mutex_unlock(&lowpan_dev_info(dev)->dev_list_mtx);

mutex_destroy(&lowpan_dev_info(dev)->dev_list_mtx);
Expand Down

0 comments on commit aec9db3

Please sign in to comment.