projects
/
project
/
netifd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4958d30
)
device: duplicate the config earlier to avoid using stale data
author
Felix Fietkau
<nbd@openwrt.org>
Wed, 5 Oct 2011 17:47:39 +0000
(19:47 +0200)
committer
Felix Fietkau
<nbd@openwrt.org>
Wed, 5 Oct 2011 17:47:39 +0000
(19:47 +0200)
device.c
patch
|
blob
|
history
diff --git
a/device.c
b/device.c
index
b260d50
..
91a7867
100644
(file)
--- a/
device.c
+++ b/
device.c
@@
-354,19
+354,24
@@
device_create(const char *name, const struct device_type *type,
enum dev_change_type change;
D(DEVICE, "Create new device '%s' (%s)\n", name, type->name);
enum dev_change_type change;
D(DEVICE, "Create new device '%s' (%s)\n", name, type->name);
+ config = config_memdup(config);
+ if (!config)
+ return NULL;
+
odev = device_get(name, false);
if (odev) {
change = device_check_config(odev, config);
switch (change) {
case DEV_CONFIG_APPLIED:
free(odev->config);
odev = device_get(name, false);
if (odev) {
change = device_check_config(odev, config);
switch (change) {
case DEV_CONFIG_APPLIED:
free(odev->config);
- odev->config = config
_memdup(config)
;
+ odev->config = config;
if (odev->present) {
device_set_present(odev, false);
device_set_present(odev, true);
}
/* fall through */
case DEV_CONFIG_NO_CHANGE:
if (odev->present) {
device_set_present(odev, false);
device_set_present(odev, true);
}
/* fall through */
case DEV_CONFIG_NO_CHANGE:
+ free(config);
return odev;
case DEV_CONFIG_RECREATE:
break;
return odev;
case DEV_CONFIG_RECREATE:
break;
@@
-374,7
+379,7
@@
device_create(const char *name, const struct device_type *type,
}
dev = type->create(config);
}
dev = type->create(config);
- dev->config = config
_memdup(config)
;
+ dev->config = config;
if (odev)
device_replace(dev, odev);
if (odev)
device_replace(dev, odev);