summaryrefslogtreecommitdiffhomepage
path: root/device.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2015-08-04 16:22:43 +0200
committerSteven Barth <steven@midlink.org>2015-08-25 08:23:29 +0200
commit9f3e8eae623da44eea2453bf2e63d5f1cba9e923 (patch)
tree649ae73849bcb3e64e36832202f1e5e89ee4e194 /device.c
parentf14e668cf0c6ebade6a4cef0ab66f13acf8e2046 (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.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/device.c b/device.c
index 6f31e36..59a57f4 100644
--- a/device.c
+++ b/device.c
@@ -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)