diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2015-08-04 16:22:43 +0200 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2015-08-25 08:23:29 +0200 |
commit | 9f3e8eae623da44eea2453bf2e63d5f1cba9e923 (patch) | |
tree | 649ae73849bcb3e64e36832202f1e5e89ee4e194 /device.c | |
parent | f14e668cf0c6ebade6a4cef0ab66f13acf8e2046 (diff) |
netifd: Fix device usage after free
Prevent new device from being freed in device_replace when
device_unlock is called along the function chain triggered
by setting the old device as not present
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'device.c')
-rw-r--r-- | device.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -704,6 +704,7 @@ device_replace(struct device *dev, struct device *odev) struct device_user *dep, *tmp; bool present = odev->present; + __devlock++; if (present) device_set_present(odev, false); @@ -713,6 +714,8 @@ device_replace(struct device *dev, struct device *odev) safe_list_add(&dep->list, &dev->users); dep->dev = dev; } + __devlock--; + device_free(odev); if (present) |