interface: fix NULL pointer defref in interface_set_main_dev
authorFelix Fietkau <nbd@openwrt.org>
Tue, 18 Jun 2013 16:24:37 +0000 (18:24 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 18 Jun 2013 16:24:51 +0000 (18:24 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
interface.c

index 81de337..ddbdca9 100644 (file)
@@ -675,6 +675,9 @@ interface_set_main_dev(struct interface *iface, struct device *dev)
                interface_set_l3_dev(iface, dev);
 
        device_add_user(&iface->main_dev, dev);
                interface_set_l3_dev(iface, dev);
 
        device_add_user(&iface->main_dev, dev);
+       if (!dev)
+               return;
+
        if (claimed)
                device_claim(&iface->l3_dev);
 
        if (claimed)
                device_claim(&iface->l3_dev);