]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lldpd: handle early cleanup in case interface cannot be created
authorVincent Bernat <vincent@bernat.im>
Sun, 31 Aug 2014 19:56:49 +0000 (21:56 +0200)
committerVincent Bernat <vincent@bernat.im>
Sun, 31 Aug 2014 19:56:49 +0000 (21:56 +0200)
When an interface is about to be created but an external condition makes
it impossible, the cleanup may crash because the interface was
incomplete. Check things exist before cleanup.

src/daemon/event.c
src/daemon/lldpd.c

index 14a3855a313f7b539604bca37cbd864291e5d448..2379d2b4b095b18e8c24aeedba76bc7672b54179 100644 (file)
@@ -570,7 +570,10 @@ void
 levent_hardware_release(struct lldpd_hardware *hardware)
 {
        struct lldpd_events *ev, *ev_next;
-       event_free(hardware->h_timer); hardware->h_timer = NULL;
+       if (hardware->h_timer) {
+               event_free(hardware->h_timer);
+               hardware->h_timer = NULL;
+       }
        if (!hardware->h_recv) return;
 
        log_debug("event", "release events for %s", hardware->h_ifname);
index 4848f6f3302ed3564a773d6a9ffaf6e7f6939e5f..d4d83189489053a709aeed81c53cc3f74ee2f959 100644 (file)
@@ -208,7 +208,7 @@ lldpd_hardware_cleanup(struct lldpd *cfg, struct lldpd_hardware *hardware)
        log_debug("alloc", "cleanup hardware port %s", hardware->h_ifname);
 
        lldpd_port_cleanup(&hardware->h_lport, 1);
-       if (hardware->h_ops->cleanup)
+       if (hardware->h_ops && hardware->h_ops->cleanup)
                hardware->h_ops->cleanup(cfg, hardware);
        levent_hardware_release(hardware);
        free(hardware);