device: Fix possible segfault
authorHans Dedecker <dedeckeh@gmail.com>
Mon, 1 Feb 2016 09:56:15 +0000 (10:56 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 1 Feb 2016 10:09:57 +0000 (11:09 +0100)
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
device.c

index 6dc4fa9b1acb92e8dc31b7b3b5e19088e1e024ed..65183f37ab505180dd8a89eddfa33524092cd87e 100644 (file)
--- a/device.c
+++ b/device.c
@@ -429,6 +429,9 @@ device_create_default(const char *name, bool external)
 
        D(DEVICE, "Create simple device '%s'\n", name);
        dev = calloc(1, sizeof(*dev));
+       if (!dev)
+               return NULL;
+
        dev->external = external;
        dev->set_state = simple_device_set_state;
        device_init(dev, &simple_device_type, name);