[OpenWrt-Devel] [PATCH 2/4] netifd: Fix device usage after free
Hans Dedecker
dedeckeh at gmail.com
Tue Aug 4 10:22:43 EDT 2015
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 at gmail.com>
---
device.c | 3 +++
1 file changed, 3 insertions(+)
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)
--
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list