fix device reload with no previous config
authorFelix Fietkau <nbd@openwrt.org>
Mon, 3 Oct 2011 01:11:30 +0000 (03:11 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 3 Oct 2011 01:11:30 +0000 (03:11 +0200)
device.c

index caadbc3cd731e156f7424b5fefba752ff421f9ad..ab8ff915ce68038de91c47ba0123e6e57c7d2d1d 100644 (file)
--- a/device.c
+++ b/device.c
@@ -305,8 +305,11 @@ device_reload_config(struct device *dev, struct blob_attr *attr)
 
        blobmsg_parse(dev_attrs, __DEV_ATTR_MAX, tb,
                blob_data(attr), blob_len(attr));
-       blobmsg_parse(dev_attrs, __DEV_ATTR_MAX, tb1,
-               blob_data(dev->config), blob_len(dev->config));
+       if (dev->config)
+               blobmsg_parse(dev_attrs, __DEV_ATTR_MAX, tb1,
+                       blob_data(dev->config), blob_len(dev->config));
+       else
+               memset(tb1, 0, sizeof(tb1));
 
        if (!config_diff(tb, tb1, &device_attr_list, NULL))
                return DEV_CONFIG_NO_CHANGE;